Awasu » Using Nexus to proxy for npm
Tuesday 9th August 2022 10:50 AM

npm is Javascript's main online repository, and is where libraries are downloaded from when you run npm install.

To configure Nexus to proxy for this, first create a new blob store for its artifacts[1]This step is optional, if you want to store the cached artifacts in their own sub-directory..

Then create a new repository, of type npm (proxy).

To configure the repo:

  • Give the repo a name (e.g. npm-proxy).
  • Use the suggested URL for the remote repository (https://registry.npmjs.org).
  • If you want to make downloaded artifacts immutable, set the Maximum component age to -1.
  • Configure the blob store you want to keep downloaded artifacts in.


Client configuration

On the client computer, we need to tell npm that it should download libraries from our instance of Nexus, instead of the usual npmjs.org:

npm config set registry http://nexus3:8081/repository/npm-proxy

If we now npm install something, we can see it appear in the Nexus admin console, where it will be available the next time it is requested.

References

References
1 This step is optional, if you want to store the cached artifacts in their own sub-directory.
Have your say