多人共用ubuntu系统,sudo npm install -g 出现rollbackfailed
背景:多人共用虚机ubuntu系统,npm 安装angular/cli 失败
尝试:
(1)npm install -g @angular/cli
报错:EACCES: permission denied, access '/usr/local/lib'
(2)sudo npm install -g @angular/cli
报错:卡在rollbackfailed,error信息:network timeout at: https://registry.npm.taobao.org/@angular%2fcli
(3)配置淘宝镜像
-
npm set registry https://registry.npm.taobao.org # 注册模块镜像
-
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
-
sudo npm install -g @angular/cli
报错:卡在rollbackfailed,error信息:network timeout at: https://registry.npm.taobao.org/@angular%2fcli
(4)配置代理
- npm config set proxy http://server:port
- npm config set http-proxy http://server:port
- npm config set https-proxy http://server:port
- npm config set no proxy http://server:port
- sudo npm install -g @angular/cli
报错:卡在rollbackfailed,error信息:network timeout at: https://registry.npm.taobao.org/@angular%2fcli
(5)怀疑sudo权限问题
https://www.jumtu.com/article/87143.html——修改默认全局安装路径
1、新建一个全局安装的路径
mkdir ~/.npm-global
2、配置npm使用新的路径
npm config set prefix ‘~/.npm-global'
3、打开或者新建~/.profile,加入下面一行
export PATH=~/.npm-global/bin:$PATH
4、更新系统环境变量
source ~/.profile
安装一个全局包试一试:
npm install -g @angular/cli