今天在安装nodejs时候,在安装npm install express时候一直报错,错误如下:
后台尝试了几种方法,最后还是没有解决。。但是,还是总结一下用了哪些方法吧。
c:\windows\system32\cmd.exe - 右键 - 管理员权限运行
npm config get proxy npm config get https-proxy
如果返回值不为null,继续执行:
npm config set proxy null npm config set https-proxy null
执行:
npm config set registry http://registry.cnpmjs.org/
淘宝的镜像:http://registry.npm.taobao.org/
官方镜像:http://registry.npmjs.org/
腾讯镜像:https://gems.ruby-china.org/
这些镜像的http和https我都试过了,我自己在公司不行,在家可以。
registry = http://registry.cnpmjs.org
npm install express -force强制安装
npm install express -g 全局安装
如果你安装如下
说明你安装成功了,这个只是警告,并不是错误,可以暂时不用管它,等到你后面接触到了包,就会知道一个标准的node项目需要有package.json。
以上就是我总结的解决npm install express错误的几种方法。