Skip to content

Private npm module support

When are npm private modules used?

Private npm modules are used at two times during Renovate's process.

1. Module lookup

If a private npm module is listed as a dependency in a package.json, then Renovate will attempt to keep it up-to-date like all other modules. By default - unless configured otherwise - Renovate will query the main npm registry like it would for a publicly scoped package. Hence, by default a private package lookup will fail, because without authentication npm will answer that the package doesn't exist. This means it won't be "renovated" and its version will remain as it is, unless you update it manually. All other modules can be looked up independently of this and Renovate can detect if they need updating.

Assuming the lookup succeeds (solutions for that are described later in this document) then private modules will be kept up-to-date like public modules are.

2. Lock file generation

If you are using a lock file (yarn's yarn.lock or npm's package-lock.json) then Renovate needs to regenerate that lock file whenever any npm module listed in your package.json is updated to a new version.

To do this, Renovate will run npm install or yarn install and save the resulting lock file. The "problem" here is that for the install to succeed - and lock file to be generated - then all touched packages must be found in the registry, including possibly private ones. Therefore if a private module can't be found, and you're using lock files, then the private module install failure might then block all modules from being renovated.

Because lock files are quickly becoming "the new standard", we think it's essential that Renovate can access/install any private modules necessary.

Supported npm authentication approaches

Authenticate the "renovate" npm user to your private npm module

The Renovate app itself runs with credentials for the "renovate" user on npm. Therefore, a simple solution to enabling private modules is to treat Renovate as another account on your team and add the npm user "renovate" to the necessary projects that Renovate needs to access. Renovate will then use its own npm authentication if it finds none in your repository.

Commit .npmrc file into repository

One approach that many projects use for private repositories is to simply check in an authenticated .npmrc or .yarnrc into the repository that is then shared between all developers. Therefore anyone running npm install or yarn install from the project root will be automatically authenticated with npm without having to distribute npm logins to every developer and make sure they've run npm login first before installing.

The good news is that this works for Renovate too. If Renovate detects a .npmrc or .yarnrc file then it will use it for its install.

Add npmrc string to Renovate config

The above solution maybe have a downside that all users of the repository (e.g. developers) will also use any .npmrc that is checked into the repository, instead of their own one in ~/.npmrc. To avoid this, you can instead add your .npmrc authentication line to your Renovate config under the field npmrc. e.g. a renovate.json might look like this:


If configured as such, Renovate will use this to authenticate with npm.

Be careful how you do this however. If you simply copy the contents from an ~/.npmrc on a developer machine and that developer ever logs out on that machine, then the token will be invalidated and Renovate will no longer be able to authenticate. Please generate the token using npm token instead, and generate it using the option --read-only.

Add npmToken to Renovate config

If you are using the main npmjs registry then you can configure just the npmToken instead:

  "npmToken": "abcdefghi-1234-jklmno-aac6-12345567889"

It's recommended that you use the npm token command to generate this token, and generate it using the option --read-only.

Add encrypted .npmrc file into repository

Even if your repository is private itself, you may still prefer not to put an unencrypted .npmrc file into your renovate config. An alternative is to put an encrypted version into the config, inside an encrypted configuration block.

If you are using the hosted Renovate app service on GitHub, you can do this using the renovate-encrypt module. To get an encrypted value, use it like this:

$ renovate-encrypt < .npmrc

(if installed globally)

or just run it without installing using npx:

$ npx renovate-encrypt < .npmrc

You will then get an encrypted string that you can substitute into your renovate.json instead, it will now look something like this:

  "encrypted": {

However be aware that if your .npmrc is too long to encrypt then the above command will fail. In that case, you should encrypt npmToken instead (see next section) and add replace the token with ${NPM_TOKEN} in the (unencrypted) npmrc in your config.

Add an encrypted npm token to repository

Similar to the above, but using npm token. As described earlier, use generate-npm-token to generate an npm token and then renovate-encrypt to encrypt it.

$ echo "abcdefghi-1234-jklmno-aac6-12345567889" | renovate-encrypt

The configure it like:

  "encrypted": {

Renovate will then use the following logic:

  1. If no npmrc string is present in config then one will be created with the _authToken pointing to the default npmjs registry
  2. If an npmrc string is present and contains ${NPM_TOKEN} then that placeholder will be replaced with the decrypted token
  3. If an npmrc string is present but doesn't contain ${NPM_TOKEN} then the file will have _authToken=<token> appended to it