npm安装Node-red dashboard 报错 与npm卸载模块

遇到npm报错read ECONNRESET怎么办

一般使用命令直接安装,由于国内被qiang的原因,没设置好安装包镜像仓库地址,一般都容易报错

npm i node-red-dashboard

遇到npm 像弱智一样报错怎么办
read ECONNRESET
This is most likely not a problem with npm itselft
'proxy' config is set properly

查看当前配置

输入 npm config ls

pi@raspberrypi:~ $  npm config ls
; cli configs
user-agent = "npm/2.15.12 node/v8.11.1 linux arm"

; userconfig /home/pi/.npmrc
registry = "http://registry.npmjs.org/"

; node bin location = /usr/bin/node
; cwd = /home/pi
; HOME = /home/pi
; 'npm config ls -l' to show all defaults.

清除npm的代理命令如下:

    npm config delete http-proxy

    npm config delete https-proxy

如果在npm install的过程中有报错,可能是某些包被Qiang掉了,请自己设置翻墙代理之后再运行npm install,设置方式示例:npm config set proxy=http://127.0.0.1:1080 ,或者用cnpm进行安装。

GFW 蛋疼的把 https://registry.npmjs.org 给墙了,导致无法通过 NPM 安装模块。
可以运行如下两句命令设置代理,注意代理的地址改为自己实际可用的代理。

npm config set proxy=http://127.0.0.1:8087
npm config set registry=http://registry.npmjs.org

想要更快装得更完全些,可以安装淘宝的cnpm.

npm install -g cnpm

如果装不上,可以加上参数安装cnpm

npm install -g cnpm --registry=http://r.cnpmjs.org
npm install node-red-dashboard --registry=http://r.cnpmjs.org --disturl=http://dist.cnpmjs.org

 其实有个办法可以,不用通过代理http://registry.npmjs.org仓库的方式,直接下载包到.node-red\node_modules,之下。直接安装。

cd ~\.node-red\node_modules
git clone https://github.com/node-red/node-red-dashboard.git
cd node-red-dashboard
npm install

npm安装模块

  • 【npm install xxx】利用 npm 安装xxx模块到当前命令行所在目录;
  • 【npm install -g xxx】利用npm安装全局模块xxx;

本地安装时将模块写入package.json中:

  • 【npm install xxx】安装但不写入package.json;
  • 【npm install xxx –save】 安装并写入package.json的”dependencies”中;
  • 【npm install xxx –save-dev】安装并写入package.json的”devDependencies”中。

npm 删除模块

【npm uninstall xxx】删除xxx模块; 
【npm uninstall -g xxx】删除全局模块xxx;

也可以参考一下文章设置更多的

NodeJS使用淘宝npm镜像站的各种姿势

https://www.jianshu.com/p/253cb9003411

淘宝 NPM 镜像

http://npm.taobao.org/ 

猜你喜欢

转载自blog.csdn.net/hu5566798/article/details/81257574