config

npm config

Reads and writes npm configuration values across user, project (.npmrc), and global levels. Alias: `c`; `npm config list -l` shows every effective setting including defaults.

npm config <get|set|delete|list|edit> [<key> [<value>]]

Common flags

Flag Purpose
--global (-g) Operate on the global config file instead of user-level
--location <user|project|global> Target a specific config file explicitly
--long (-l) Include default values when listing
--json Emit config values as JSON

Examples

npm config get registry

Print the current registry URL

npm config set registry https://registry.npmjs.org/

Reset to the public registry

npm config list -l

Show every effective config value with defaults

npm config set save-exact=true

Pin exact versions on future installs

Gotcha

Never commit auth tokens to a project-level `.npmrc` — put them in `~/.npmrc` or reference an env var like `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`. Config precedence cascades: cli > env > project > user > global > defaults.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM