Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm rollbackFailedOptional error when install any package

Tags:

node.js

npm

I have a problem when installing any npm packages. here is my error:

rollbackFailedOptional: verb npm-session xxxxxxxxxxx

for resolving this I do some stuff but I still get the same error.

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

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?

Update: npm config list:

; 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:[email protected]:6050/"
proxy = "http://username:[email protected]: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.
like image 970
prodigy Avatar asked May 13 '18 11:05

prodigy


People also ask

Why npm is not installing?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.


1 Answers

I had resolved this identical issue by pointing the npm to the correct proxy when using a corporate machine. NO ADMIN REQUIRED!!!

Here are my steps:

  1. Obtain the correct proxy by following these steps here! Copy/paste the proxy address into notepad. You will use this same proxy to set both the 'proxy' and 'proxy-https' params in the next step.

  2. Execute the following 2 commands in your command window by replacing <contents> below with proxy address obtained in previous step:

    • npm config set proxy http://<proxy-server-url:port>
    • npm config set https-proxy http://<proxy-server-url:port>

NOTE: I ommitted 'username' and 'password' fields from the 'http://<username><password>@<proxy-server-url:port>' template which according to the source should work 9 out of 10 times, and worked perfectly for me.

  1. Navigate to your project folder from the command line and execute 'npm install <package name(s)>'. The installation should be successfull.
like image 182
DeezKnutson Avatar answered Sep 27 '22 17:09

DeezKnutson