该问题一般情况是因为代理问题,npm代理和git代理都要设置。首先确认网络是否需要设置代理。
如果是公司网络需要设置代理,则设置npm代理和git代理
1、设置npm代理
1 | npm config set proxy http://127.0.0.1:1080 |
2 | npm config set https-proxy http://127.0.0.1:1080 |
如果代理需要认证的话可以这样来设置
1 | npm config set proxy http://username:password@server:port |
2 | npm config set https-proxy http://username:pawword@server:port |
2、设置git代理
1 | git config --global http.proxy http: //127 .0.0.1:1080 |
2 | git config --global https.proxy https: //127 .0.0.1:1080 |
如果所用网络不需要代理,则要把npm代理和git代理去掉
1、去掉npm代理
1 | npm config delete proxy |
2 | npm config delete https-proxy |
2、去掉git代理
1 | git config --global -- unset http.proxy |
2 | git config --global -- unset https.proxy |
设置完成后,再试一下就可以了。
转载:http://www.liuchang.org/npm-zhuang-bao-cuo-rollbackfailedoptional-verb-npm-session-jie-jue-ban-fa/