Once you set up your hosted and proxy repositories and create a repository group to merge them, you can access
them with the
npm tool on the command line as one registry.
As shown below, you can configure the registry used by
npm in your
.npmrc file located in your user’s home
directory. If the file does not exist simply create it and add the registry configuration with the URL of your
npm repository group. You can find the public URL of your group repository in the repository list in the
Repository Path column.
Registry configuration in
registry = http://localhost:8081/nexus/content/groups/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
$ 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
By default any anonymous user has read access to the repositories and repository groups. If desired, the
repository manager can be configured to require authentication by adding
always-auth=true to the
and adding the encoded authentication details as documented in Section 16.6, “Publishing npm Packages”.