Configuring npm
Once you have set up your hosted and proxy repositories for npm packages and created a repository group to merge them, you can access them with the npm tool on the command line as one registry.
Note
Once you create an npm proxy repository, do not change the remote server URL. Doing so may result in 404s as Nexus Repository attempts to retrieve cached data. Instead, create a new proxy repository.
You can configure the npm registry in the .npmrc file in your user home directory by using the npm config command with the public URL of your repository group.
To copy the repository group URL, select the copy button in the URL column on either the Settings → Repository → Repositories page or the Browse page.
For example:
npm config set registry http://localhost:8081/repository/npm-all/
The command inserts the configuration in the .npmrc file in your users home directory.
Registry configuration in .npmrc
registry = http://localhost:8081/repository/npm-all/
With this configuration, any npm commands will use the new registry from the repository manager. The command line output will reference the URLs in --verbose mode or with info logging for the downloads of the requested packages:
$ npm --loglevel info install grunt ... npm http fetch GET http://localhost:8081/repository/npmjs-org/grunt/-/grunt-0.4.5.tgz npm http fetch 200 http://localhost:8081/repository/npmjs-org/grunt/-/grunt-0.4.5.tgz ... npm http fetch GET http://localhost:8081/repository/npm-all/underscore/-/underscore-1.7.0.tgz npm http fetch 200 http://localhost:8081/repository/npm-all/underscore/-/underscore-1.7.0.tgz ...