安装ws
1、更改npm源
解决方法:
更换成淘宝的源
1 | npm config set registry https: //registry .npm.taobao.org |
– 配置后可通过下面方式来验证是否成功
1 | npm config get registry |
– 或
1 | npm info express |
2、使用cnpm
先删除原有的所有代理
1 2 | npm config rm proxy npm config rm https-proxy |
然后使用
1 | npm install -g cnpm --registry=https: //registry .npm.taobao.org |
安装淘宝的cnpm
就可以使用淘宝的cnpm了
如果网络问题,无法安装,可用淘宝镜像安装,先到网站目录下,执行本地安装
1 | npm install ws --registry=http: //registry .npm.taobao.org |
如果用
1 | npm install ws -g --registry=http: //registry .npm.taobao.org |
全局安装,
会报:
Cannot find module ‘ws’ 错误!
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持IT俱乐部。