npm has become the standard dependency management software for javascript. Dependencies are configured inside a package.json configuration file and downloaded from the public registry https://www.npmjs.com/. Publishing to a public repository is an option for open source projects, but not for private packages.
npmjs.com offers commercial solutions to manage private packages, the price range is between 7 and 20 USD, depending of the selected product range.
Another solution is to host a private registry, most maven repository servers are capable to manage npm registries.
Following steps are necessary to configure the nexus repository manager to manage public and private npm packages:
Step 1: Download and configure the nexus repository manager software (if required)
Step 2: Create a hosted npm repository, ex. npm-internal
Step 3: Create a npm proxy repository, ex. npm-public
which points to the remote registry https://registry.npmjs.org
Step 4: Create a npm repository group, ex. npm-all
and add npm-internal
and npm-public
as members
Step 5: Add npm Bearer Token to the realm settings
The setup steps for the client software are:
Step 1: Configure the nexus managed repository
npm config set registry http://<host:port>/repository/npm-all/
Step 2: Login for publish
npm login –registry=http://<host:port>/repository/npm-internal/ --always-auth
Step 3: Configure for publish
npm publish --registry http://<host:port>/repository/npm-internal/
or inside package.json
"publishConfig" : {
"registry" : "http://<host:port>/repository/npm-internal/"
}