Skip to content

npm

.npmrc

npm的配置文件

value如果是字符串是不需要使用双引号包裹的

ini
registry=https://registry.npmmirror.com/
strict-ssl=false
save-exact=true
cache=/path/to/npm-cache
  • 优先级:项目目录 .npmrc > 用户目录 ~/.npmrc > 全局配置 /etc/npmrc

警告

.npmrc 不是 npm 私有的,它的网络、证书、认证配置可能间接污染 Yarn / pnpm,在多管理器仓库里,务必给每个工具显式提供自己的配置文件,避免“幽灵配置”。

命令

查看pkg所有的版本

sh
npm view <pkg> versions
sh
[
  '1.0.0',
  '2.0.0',
  '2.7.16',
  '3.0.0',
  '3.4.21'
]

查看pkg的最新版本

sh
npm view <pkg> version
ts
3.5.27

查看镜像地址

sh
npm config get registry
sh
https://registry.npmmirror.com

设置镜像地址

sh
npm config set registry https://registry.npmmirror.com/

指定镜像地址安装包

sh
npm i sequelize --registry=https://registry.npmmirror.com