0
点赞
收藏
分享

微信扫一扫

npm install 报错解决

云竹文斋 2022-04-13 阅读 79
node.js

npm安装源设置

npm默认源是国外网站,国内访问不了,无法获取依赖包信息。更换为国内的安装源即可。

// 查看自己的安装源
npm config get registry
// 更换npm源为国内淘宝镜像
npm config set registry http://registry.npm.taobao.org/
// 或者更换为国内npm官方镜像
npm config set registry http://registry.cnpmjs.org/
// 还原npm源
npm config set registry https://registry.npmjs.org/

还可以设置代理,以及编辑配置文件等。

// 命令行设置代理
npm config set proxy="http://127.0.0.1:1034"
// 还可以直接使用npm设置,不需要config
npm --registry https://registry.npm.taobao.org info underscore
举报

相关推荐

0 条评论