Skip to content

Commit

Permalink
docs: npmrc hostRules recommendation
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 18, 2021
1 parent b21959f commit 199cfaa
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/usage/private-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ It's therefore better to provide Renovate with all the credentials it needs to l

The recommended approaches in order of preference are:

**If you are running your own Renovate bot**: copy an `.npmrc` file to the home dir of the bot and it will work for all repositories
**Self-hosted hostRules**: Configure a hostRules entry in the bot's `config.js` with the `hostType`, `hostName` and `token` specified

**Self-hosted .npmrc**: copy an `.npmrc` file to the home dir of the bot.

**Renovate App with private modules from npmjs.org**: Add an encrypted `npmToken` to your Renovate config

Expand All @@ -41,12 +43,30 @@ All the various approaches are described below:

### Commit .npmrc file into repository

Define `hostRules` like this:

```js
module.exports = {
hostRules: [
{
hostType: 'npm',
hostName: 'registry.npmjs.org',
token: 'abc123',
},
],
};
```

### Commit .npmrc file into repository

One approach that many projects use for private repositories is to simply check in an authenticated `.npmrc` 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.

Does not work if using binarySource=docker.

### 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`.
Expand Down

0 comments on commit 199cfaa

Please sign in to comment.