-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
npm config
在使用nodejs过程中,npm是我们常用到的工具。
输入npm config -h,可以看到如下的操作说明:
npm config set <key> <value> [-g|--global]
npm config get <key>
npm config delete <key>
npm config list [-l] [--json]
npm config edit
npm get <key>
npm set <key> <value> [-g|--global]
aliases: c现在来介绍一下它的配置字段的含义。
npm conifg list
输入npm config list --json,查看本机的配置:
{
"json": true,
"user-agent": "npm/6.9.0 node/v10.15.3 win32 x64",
"metrics-registry": "https://registry.npmjs.org/",
"scope": "",
"prefix": "C:\\Users\\Alpha\\AppData\\Roaming\\npm",
"access": null,
"allow-same-version": false,
"always-auth": false,
"also": null,
"audit": true,
"audit-level": "low",
"auth-type": "legacy",
"before": null,
"bin-links": true,
"browser": null,
"ca": null,
"cache": "C:\\Users\\Alpha\\AppData\\Roaming\\npm-cache",
"cache-lock-stale": 60000,
"cache-lock-retries": 10,
"cache-lock-wait": 10000,
"cache-max": null,
"cache-min": 10,
"cert": null,
"cidr": null,
"color": true,
"depth": null,
"description": true,
"dev": false,
"dry-run": false,
"editor": "notepad.exe",
"engine-strict": false,
"force": false,
"fetch-retries": 2,
"fetch-retry-factor": 10,
"fetch-retry-mintimeout": 10000,
"fetch-retry-maxtimeout": 60000,
"git": "git",
"git-tag-version": true,
"commit-hooks": true,
"global": false,
"globalconfig": "C:\\Users\\Alpha\\AppData\\Roaming\\npm\\etc\\npmrc",
"global-style": false,
"group": 0,
"ham-it-up": false,
"heading": "npm",
"if-present": false,
"ignore-prepublish": false,
"ignore-scripts": false,
"init-module": "C:\\Users\\Alpha\\.npm-init.js",
"init-author-name": "",
"init-author-email": "",
"init-author-url": "",
"init-version": "1.0.0",
"init-license": "ISC",
"key": null,
"legacy-bundling": false,
"link": false,
"loglevel": "notice",
"logs-max": 10,
"long": false,
"maxsockets": 50,
"message": "%s",
"node-options": null,
"node-version": "10.15.3",
"offline": false,
"onload-script": null,
"only": null,
"optional": true,
"otp": null,
"package-lock": true,
"package-lock-only": false,
"parseable": false,
"prefer-offline": false,
"prefer-online": false,
"preid": "",
"production": false,
"progress": true,
"proxy": null,
"https-proxy": null,
"noproxy": null,
"read-only": false,
"rebuild-bundle": true,
"registry": "https://registry.npmjs.org/",
"rollback": true,
"save": true,
"save-bundle": false,
"save-dev": false,
"save-exact": false,
"save-optional": false,
"save-prefix": "^",
"save-prod": false,
"script-shell": null,
"scripts-prepend-node-path": "warn-only",
"searchopts": "",
"searchexclude": null,
"searchlimit": 20,
"searchstaleness": 900,
"send-metrics": false,
"shell": "C:\\WINDOWS\\system32\\cmd.exe",
"shrinkwrap": true,
"sign-git-commit": false,
"sign-git-tag": false,
"sso-poll-frequency": 500,
"sso-type": "oauth",
"strict-ssl": true,
"tag": "latest",
"tag-version-prefix": "v",
"timing": false,
"tmp": "C:\\Users\\Alpha\\AppData\\Local\\Temp",
"unicode": false,
"unsafe-perm": true,
"update-notifier": true,
"usage": false,
"user": 0,
"userconfig": "C:\\Users\\Alpha\\.npmrc",
"umask": 0,
"version": false,
"versions": false,
"viewer": "browser",
"globalignorefile": "C:\\Users\\Alpha\\AppData\\Roaming\\npm\\etc\\npmignore"
}
关键字段解析
- user-agent,宿主主机信息,包括npm、node版本
- metrics-registry,当send-metrics设置为true时候会把npm CLI成功或失败的信息上传到metrics-registry,默认值同registry
- scope,登录的时候可以设置为组织名字
- prefix,全局安装路径前缀
- access,"restricted" | "public",默认为restricted,发布包时候用到
- allow-same-version,是否允许
- always-auth,默认值为false,每次访问registry是否需要验证身份
- cache,npm的缓存目录
- dev,是否安装包里的dev-dependencies
- editor,
npm edit或者npm config edit会调用的程序 - engine-strict,默认为false,如果为true将不会安装不兼容当前nodejs版本的包
- git-tag-version,默认值为true,使用npm version的时候会提交一个git版本
- commit-hooks,默认值为true,使用npm version指令的时候会运行git commit hooks
- global,默认值为false,即默认安装在当前目录而不是prefix指示的全局安装路径
- globalconfig,全局配置文件位置
- heading,输出的调试日志的头部标识
- https-proxy,https代理
- ignore-prepublish,默认值为false,即不会忽略prepublish脚本
- ignore-scripts,默认值为false,即不会忽略package.json里scripts字段的脚本
- loglevel,日志等级
- message,使用npm version的时候提交的git commit信息,%s为占位符(表示版本)
- offline,断网模式,允许使用cache
- production,默认为false,如果为true的话:
npm install不会安装devDependencies,同时会设置NODE_ENV="production" - proxy,htpp代理
- registry,包仓库,默认为官方:https://registry.npmjs.org/
- rollback,默认值为true,安装失败的时候移除包
- save,默认值为true,安装的依赖会放到dependencies对象上
- save-prefix,默认值为^,保存前缀
- script-shell,当npm run运行脚本时会执行的脚本
- userconfig,用户配置
参考
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels