npm install 常见错误

常用npm命令:https://www.runoob.com/nodejs/nodejs-npm.html
npm文档:中文文档

错误1: ERR: Please try running this command again as root/Administrator
说明: 提示要用管理员身份重新安装,网上有说要清除缓存,尝试了行不通。
Please try running this command again as root/Administrator
解决: 直接重新安装(多半是网络原因

或者登录用户(尝试了有时候可以)再重新安装
>npm login
Username: test
Password: ******
Email: *******
>npm install --save module

tip:登录之后安装还是报错的话,就多试几次,网络差的情况下也有可能导致安装失败。(错误提示就是让你重新安装)

错误2: ERR! network ‘proxy’ config is set properly
原文错误翻译: 如果有代理就把代理配置正确。

network 'proxy' config is set properly
解决:我们这里不使用代理直接设置为null。

>npm config set proxy null
>npm config set https-proxy null
把这两个代理都设置设为null 就可以了。
也可以找到配置文件.npmrc 中进行修改。

错误3: npm publish

ERR! You cannot publish over the previously published versions
err:您不能在以前发布的版本上发布。 每次发布都要修改版本号,要修改version

npm config get registry   // 查看
npm config set registry=http://registry.npmjs.org  // npm镜像 
npm config set registry=https://registry.npm.taobao.org/  // 淘宝镜像
npm config list  //查看配置可以看到配置目录: userconfig C:\Users\Administrator\.npmrc

如果当前是淘宝镜像发布是发布不成功的

切换 npm config set registry=http://registry.npmjs.org

再进行发布。 要确定是登录的状态下呦。

错误4: npm 启动项目
ERR! webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
ERR! This is probably not a problem with npm. There is likely additional logging output above.
在这里插入图片描述
解决:清除缓存,重新安装依赖。

删除node_modulespackage-lock.json文件
npm cache 介绍

>npm cache clear --force
>npm install
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值