Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install Error: rollbackFailedOptional

When I try npm install new packages it shows me this error:

rollbackFailedOptional: verb npm-session 585aaecfe5f9a82

node --version
8.4.0

npm --version
5.3.0
like image 908
Bipul Prasai Avatar asked Sep 02 '17 07:09

Bipul Prasai


People also ask

Why do we need .npmrc file?

npmrc is the configuration file that npm allows to be used globally or user level or project level to optimize your npm environment.

How do I update npm package manager?

Method 1: Using npm update command to update the node package manager. Method 2: Using npm@latest command to update the node package manager. Method 3: Using PPA repository (only for Linux). Method 4: Using cache cleaning & stable installing (only for Linux).

How do I reinstall node JS?

To use the official Node installer for reinstalling the tools, go to the Node. js download page and select the version you want to install—just as we described previously. Remember to choose the macOS installer option. If you run the installer, it will complete the reinstallation process for you automatically.


11 Answers

    # first this
    > npm config rm proxy
    > npm config rm https-proxy

    # then this
    > npm config set registry https://registry.npmjs.org/

solved my problem.

Again: Be sure to check whether you have internet connected properly.

like image 57
anvarik Avatar answered Oct 06 '22 04:10

anvarik


Try this

npm config rm proxy
npm config rm https-proxy
like image 40
cwtuan Avatar answered Oct 06 '22 05:10

cwtuan


In my case I had to edit the .npmrc directly and add the proxy settings manually.

proxy=http://yourorganizationproxy.com:8080
https-proxy=http://yourorganizationproxy.com:8080

Hope this helps someone.

like image 43
miqrc Avatar answered Oct 06 '22 04:10

miqrc


The cause for this might be your current NPM registry. Try to check for a .npmrc file. These can be at various locations:

  • per-project config file (/path/to/my/project/.npmrc)
  • per-user config file (~/.npmrc)
  • global config file ($PREFIX/etc/npmrc)
  • npm builtin config file (/path/to/npm/npmrc)

Within these there can be something like

registry=https://mycustomregistry.example.org

which will take priority over the default one (http://registry.npmjs.org/). You can delete this line in the file or use the default registry like that:

npm <command> --registry http://registry.npmjs.org/
like image 45
lambda Avatar answered Oct 06 '22 06:10

lambda


Most likely to be npm registry cannot be reached by npm. Check npm proxy configuration

I had exactly the same issue on Windows Server 2008 R2. I suspected Internet Explorer's Enhanced Security Configuration at first but after turning that off with no success the issue turned out to be that npm was not configured to use my corporate proxy connection to the internet.

It turns out that npm does not use the proxy settings in effect via Internet Options > Connections tab > LAN settings where the server is set to 'Automatically detect settings'. Being set to automatically detect settings does not guarantee that a proxy is indeed being used, it just means that Windows will automatically configure proxy settings for Internet Explorer if it finds a special'wpad.dat' file at http://wpad.[yourdomain.com]/wpad.dat.

You can test whether a wpad.dat file is in use in your organisation by typing the following into a web browser.

http://wpad.[yourcompany.domain]/wpad.dat

If no file is available then it is likely you are not using an organization-wide proxy. If one does get returned to the browser then...

Toward the bottom of this file, you should see a line saying

PROXY <host:port>;

It might be repeated if you have multiple proxies available. The host and port are needed in order to tell npm to use the proxy settings like so:

npm config set proxy http://[host]:[port]

and

npm config set https-proxy http://[host]:[port]

For example if your proxy is at my.proxy.com on port 8080 then the npm commands would be:

npm config set proxy http://my.proxy.com:8080
npm config set https-proxy http://my.proxy.com:8080

Once I had told npm which proxy to use all started working in I was able to run the install commands without a problem.

Thanks to the following post for help with the wpad file discovery.

like image 21
AnotherLongUsername Avatar answered Oct 06 '22 05:10

AnotherLongUsername


In my case I had my npm set registry set to https://nexus, use:

npm config delete registry

This will revert to its default state.

like image 24
Luis Acero Avatar answered Oct 06 '22 04:10

Luis Acero


I tried following options to fix this issue and it worked.

  1. Uninstall Node.js version 8.
  2. Install Node.js version 6.11.4
  3. Use the registry option along with command to install any package.

For example to install express I used following command.

npm install express --registry http://registry.npmjs.org/

or

npm install express -g --registry http://registry.npmjs.org/

If you want to install locally in any specific folder then use below command. Below command will install express on path C:\Sample\Example1 .

C:\Sample1\Example1> npm install /Sample/Example1 express --registry http://registry.npmjs.org/

Note: If you are installing locally in a specific location then first go to that directory using command and then run above command. If you are not inside that directory and giving only path in command that will not work.

If you get package.json missing error then run below command before installing package locally

C:\Sample\Example1> npm init

above command will create package.json file. No need to provide any data. just hit enter.

Note: If you are behind a firewall then you may need to set a proxy.

like image 30
Anil Avatar answered Oct 06 '22 05:10

Anil


Hi I'm also new to react and I also faced this problem after so many trouble I found solution: Just run in your command prompt or terminal :

npm config set registry http://registry.npmjs.org/

This will resolve your problem. Reference link: http://blog.csdn.net/zhalcie2011/article/details/78726679

like image 39
Rails Developer Avatar answered Oct 06 '22 05:10

Rails Developer


Make sure you can access the corporate repository you configured in npm is available.Check you VPN connection.

Else reset it back to default repository like below.

npm config set registry http://registry.npmjs.org/

Good Luck!!

like image 31
Rudra Avatar answered Oct 06 '22 05:10

Rudra


The following commands resolved my issue:

npm config set proxy http://yourproxyurl.com:8080  (you need to enter your or your company proxy URL and 8080 should be replaced by your proxy port)

npm config set https-proxy http://yourproxyurl.com:8080
like image 21
Brooklyn99 Avatar answered Oct 06 '22 05:10

Brooklyn99


I had the same effect creating a react app with PhpStorm. And then at the end it just says done. Running the same command in the terminal gave me detailed errors. The project folder I've created was named react which seems to be a no-go.

Make sure your project folder is not named react.

like image 43
Markus Zeller Avatar answered Oct 06 '22 05:10

Markus Zeller