.npmrc
.npmrc is a small config file that changes how npm behaves, such as the registry or auth tokens.
In this page:
Syntax
registry=https://registry.example.com/
save-exact=true
fund=false
.npmrc
npm reads .npmrc from the project, your home directory and globally, with the project file taking priority. Common settings include registry, save-exact and scoped registries.
Never commit files containing auth tokens; use environment variables in them instead.
Note:
Use ${NPM_TOKEN} placeholders in .npmrc and set the variable in CI.
Example: .npmrc
# .npmrc
registry=https://registry.npmjs.org/
save-exact=true
@mycompany:registry=https://npm.mycompany.com/
//npm.mycompany.com/:_authToken=${NPM_TOKEN}
⚠️ Run this in your own terminal or Node.js environment.
Related Topics
Common Mistakes
- Committing auth tokens
- Editing the global file when a project one is intended
- Forgetting scope-specific registries
Chapter Summary
- .npmrc configures npm
- Project file overrides user file
- Store tokens in env variables
- Scopes can point to private registries
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: