安装任何软件包时出现 npm rollbackFailedOptional 错误 [英] npm rollbackFailedOptional error when install any package
问题描述
我在安装任何 npm
包时遇到问题.这是我的错误:
I have a problem when installing any npm
packages. here is my error:
rollbackFailedOptional: 动词 npm-session xxxxxxxxxxx
为了解决这个问题,我做了一些事情,但我仍然遇到同样的错误.
for resolving this I do some stuff but I still get the same error.
我将 registry=http://registry.npmjs.org/
放在我的用户文件夹中的 .npmrc
文件中,并运行以下命令:
I put registry=http://registry.npmjs.org/
in .npmrc
file in my user folder and also run following commands:
npm config rm proxy
npm config rm https-proxy
我尝试解决节点8.11.1
和节点10.1.0
中的问题,我的npm版本是5.6.0
.
I try to solve the problem in node 8.11.1
and node 10.1.0
and my npm version is 5.6.0
.
为什么会出现这个问题以及如何解决?
Why this problem occurs and how can resolve that?
更新:npm 配置列表:
; cli configs
metrics-registry = "http://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v8.11.1 win32 x64"
; userconfig C:\Users\me\.npmrc
https-proxy = "https://username:password@proxy.company.com:6050/"
proxy = "http://username:password@proxy.company.com:6050/"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\\Users\\me\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\me
; HOME = C:\Users\me
; "npm config ls -l" to show all defaults.
推荐答案
我已经尝试了各种论坛中发布的几乎所有方法,例如 stackoverflow、github-issues 等.但似乎没有任何效果.以下是我按顺序执行的命令,我鼓励您尝试这些命令,因为它适用于许多人(但不适用于我):
I've tried almost all methods posted in various forums like stackoverflow, github-issues etc.. but nothing seemed to work. Here are the commands I've executed in order which I encourage you to try because it worked for many people (but not me):
npm 配置 rm 代理
npm config rm https-proxy
npm 配置集 https-proxy https://username:password@proxy.company.com:6050
npm 配置设置代理 http://username:password@proxy.company.com:6050
npm 配置设置注册表 http://registry.npmjs.org/
然后当尝试安装包 npm install -g express
时 - 它失败了.
And then when trying to install the package npm install -g express
- it failed.
但是,当我尝试运行 npm install npm@latest -g
时,它奇迹般地执行并安装得很好!然后再次运行 npm install -g express
也能正常工作.
However, when I tried to run npm install npm@latest -g
it miraculously executed and installed fine!
Then running npm install -g express
again worked perfectly fine too.
TL;DR:更新 npm 到最新版本解决了这个问题(目前是 6.0.1)
TL;DR: updating npm to the latest version solved the issue (currently 6.0.1)
这篇关于安装任何软件包时出现 npm rollbackFailedOptional 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!