Struggled with this issue for some time before figuring it out.
I'm using High Sierra (10.13.6)
Uninstalled and re-installed node and nvm multiple times - using the installer.pkg
, HomeBrew
, and then using the command line. IMO, the command line works the best.
I followed these steps:
1. Ran npm config ls -l
2. Checked that the value for globalconfig
was $<installpath>/.nvm/versions/node/v12.16.3/etc/npmrc
But when I tried to get to this path in the Terminal, it gave me No such file or directory
So I
3. created the folder etc
, created the npmrc
file and added this line in it.
registry = "https://registry.npmjs.org/"
I do not have the ~/.npmrc
file in my $HOME
Then
4. I re-ran the npm install
command.
Note that this still threw the rollbackFailedOptional: verb npm-session
error, but this time it completed, though with a different error.
You could try these steps and see if it works.
For those who are curious, it threw a Response timeout while trying to fetch https://registry.npmjs.org/<package> (over 30000ms)
error, so I added the timeout = "60000"
to the /etc/npmrc
file (as found on another Stackoverflow thread), and tried again. This worked for me.
Hope this helps!