Linux command
npm-config 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List all config
npm config list
Get config value
npm config get [registry]
Set config value
npm config set [registry] [https://registry.npmjs.org/]
Delete config
npm config delete [key]
Edit config file
npm config edit
List all with defaults
npm config list -l
Set global config
npm config set [key] [value] -g
说明
npm config manages npm configuration across multiple levels. It reads settings from the command line, environment variables, and .npmrc files (project, user, and global). Configuration files are plain ini-formatted lists of key = value pairs. Environment variables prefixed with npm_config_ are also recognized as configuration settings.
参数
- set _KEY=VALUE_
- Set a config value.
- get _KEY_
- Echo a config value to stdout.
- list
- Show all config settings. Use -l to show defaults. Use --json for JSON output.
- delete _KEY_
- Remove a key from all configuration files.
- edit
- Open the config file in an editor. Use --global to edit the global config.
- fix
- Repair invalid configuration entries.
- -g, --global
- Operate on the global configuration file.
- --location _user|global|project_
- Target a specific configuration level.
FAQ
What is the npm-config command used for?
npm config manages npm configuration across multiple levels. It reads settings from the command line, environment variables, and .npmrc files (project, user, and global). Configuration files are plain ini-formatted lists of key = value pairs. Environment variables prefixed with npm_config_ are also recognized as configuration settings.
How do I run a basic npm-config example?
Run `npm config list` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does set _KEY=VALUE_ do in npm-config?
Set a config value.