Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix npm update error? (# npm install npm@latest -g)

Tags:

node.js

npm

How to fix npm update error? I run as root

# npm install npm@latest -g

usr/lib
└── (empty)

npm ERR! Linux 4.10.14-200.fc25.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "npm@latest" "-g"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules/npm/node_modules/node-gyp
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir

npm ERR! EEXIST: file already exists, mkdir '/usr/lib/node_modules/npm/node_modules/node-gyp'
npm ERR! File exists: /usr/lib/node_modules/npm/node_modules/node-gyp
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
npm ERR! code 1

And end up without npm.

The log file is at https://www.dropbox.com/s/2maxolbxjlnnp7c/npm-debug_error.log.txt?dl=0

my node version is 6.10.2, using fedora core 25 64bits. The npm version was 3.10.10

I also create an issue on https://github.com/npm/registry/issues/168

Now, npm is not installed:

npm

-bash: /usr/bin/npm: No such file or directory

I'm following the https://github.com/brock/node-reinstall tomorrow, trying a full node uninstall and reinstall if no other advise found.

I run this npm update since it's the sugested first step for installing polymer-cli in polymer 2.0

https://www.polymer-project.org/2.0/docs/tools/polymer-cli

like image 315
Pedro Polonia Avatar asked May 20 '17 21:05

Pedro Polonia


3 Answers

Firstly, I do not recommend running npm commands as root user, check this question and answer for recommendations here Running npm as root could cause you problems in the future.

You can update npm using npm as follows:

npm i -g npm-upgrade

If you have permission errors, check here how to fix them

Now for your particular error, it seems that you must erase the folder:

/usr/lib/node_modules/npm/node_modules/node-gyp

I recommend removing your node and installing it again.

like image 189
A Monad is a Monoid Avatar answered Nov 15 '22 10:11

A Monad is a Monoid


I solve the issue, running as root

# dnf remove nodejs
# dnf install nodejs
like image 6
Pedro Polonia Avatar answered Nov 15 '22 10:11

Pedro Polonia


try with sudo

sudo npm i -g npm@latest
like image 5
Yusufbek Avatar answered Nov 15 '22 11:11

Yusufbek