0

I’m and trying to update my Node and npm version on the latest Ubuntu, but I’m stuck. I tried every solution I found on the Internet — changing permissions, complete uninstall and reinstall — but still nothing works. Any advice how to solve this issue?

    MYUSER@MYUSER-VirtualBox:~$ npm update -g
    npm WARN optional dep failed, continuing readable-stream@1.1.13
npm ERR! Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/init-            package-json/node_modules/semver'
npm ERR! { [Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/init-package-json/node_modules/semver']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/init-package-json/node_modules/semver',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/init-package-json/node_modules/semver',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack: 
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-33-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/MYUSER
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! path /home/MYUSER/.node/lib/node_modules/npm/node_modules/init-package-json/node_modules/semver
npm ERR! fstream_path /home/MYUSER/.node/lib/node_modules/npm/node_modules/init-package-json/node_modules/semver
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/init-package-json/node_modules/semver'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! error rolling back Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/dezalgo/node_modules/asap'
npm ERR! error rolling back { [Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/dezalgo/node_modules/asap']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/dezalgo/node_modules/asap' }
npm ERR! Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar'
npm ERR! { [Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack: 
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-33-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/MYUSER
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! path /home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar
npm ERR! fstream_path /home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request'
npm ERR! { [Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack: 
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-33-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/MYUSER
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! path /home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request
npm ERR! fstream_path /home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/node-gyp/node_modules/request'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! error rolling back Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/tar'
npm ERR! error rolling back { [Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/tar']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/tar' }
npm ERR! error rolling back Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex'
npm ERR! error rolling back { [Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex' }
npm ERR! Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules'
npm ERR! { [Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/semver',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack: 
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-33-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/MYUSER
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! path /home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules
npm ERR! fstream_path /home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/semver
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/normalize-package-data/node_modules'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request'
npm ERR! { [Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack: 
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-33-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/MYUSER
npm ERR! node -v v0.10.38
npm ERR! npm -v 1.4.28
npm ERR! path /home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request
npm ERR! fstream_path /home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/MYUSER/.node/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! error rolling back Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/request'
npm ERR! error rolling back { [Error: EACCES, unlink '/home/MYUSER/.node/lib/node_modules/npm/node_modules/request']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/home/MYUSER/.node/lib/node_modules/npm/node_modules/request' }
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR! /home/MYUSER/npm-debug.log
npm ERR! not ok code 0
1

As I stated I tried this... It was still returning the same version of both node and npm.

I solved the problem by following again these steps for complete removal :

go to /usr/local/lib and delete any node and node_modules
go to /usr/local/include and delete any node and node_modules directory
if you installed with brew install node, then run brew uninstall node in your terminal
check your Home directory for any local or lib or include folders, and delete any node or node_modules from there
go to /usr/local/bin and delete any node executable
You may need to do the additional instructions as well:

sudo rm /usr/local/bin/npm
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm
sudo rm -rf ~/.node-gyp
sudo rm /opt/local/bin/node
sudo rm /opt/local/include/node
sudo rm -rf /opt/local/lib/node_modules

After that I installed node from git :

git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

And one final system reboot solved the issue. Thanks for answer though.

0

Sometimes looking more closely to the log you can find amazing things, like

npm ERR! Please try running this command again as root/Administrator.

Which leads to my suggestion, retry with sudo

sudo npm update -g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.