sudo ……
# 例:sudo npm i
npm install --legacy-peer-deps
npm install [包名] --legacy-peer-deps
npm config get registry
或
npm config list
国外镜像:https://registry.npmjs.org/ 国内淘宝镜像:https://registry.npm.taobao.org
命令行中添加
--registry
关键字
npm info
npm --registry <url> info [包名]
# 例:npm --registry https://registry.npm.taobao.org info express
npm install
npm install [包名] --registry=<url>
# 例:npm install --registry=https://registry.npm.taobao.org
修改
config
中的配置项
npm config set registry <url>
# 例:npm config set registry https://registry.npm.taobao.org
安装插件
npm install -g npm-check
检查package.json中所有可更新的包
npm-check
更新所有依赖到新版本
npm-check -u // 注意,更新的只是package.json下依赖的版本号
重新npm
npm install // 要是不放心,可以先把所有包删除,再重新npm install