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
npm publish
Uploads the current package to the registry so it can be installed by others. Honors the `files` field, `.npmignore`, and .gitignore to decide which files ship.
npm install
Installs a package (and its dependencies), adding it to package.json and refreshing package-lock.json. Without arguments, installs everything already declared in the current project's package.json.
npm ci
Performs a clean, deterministic install straight from package-lock.json (or npm-shrinkwrap.json) intended for CI environments. It deletes any existing node_modules and refuses to run if package.json and the lockfile are out of sync.