Error installing cordova with npm under ubuntu 15.10
If you try install cordova like this :
[pastacode lang= »bash » message= » » highlight= » » provider= »manual »]
npm install -g cordova
[/pastacode]
And you have some access file error :
[pastacode lang= »bash » message= » » highlight= » » provider= »manual »]
npm ERR! tar.unpack untar error /home/user/.npm/cordova/5.4.0/package.tgz
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/cordova',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/nodejs/fstream/lib/writer.js:171:23',
npm ERR! '/usr/lib/nodejs/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 4.2.0-18-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "cordova"
npm ERR! cwd /home/user
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! path /usr/local/lib/node_modules
npm ERR! fstream_path /usr/local/lib/node_modules/cordova
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules'
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:171:23
npm ERR! fstream_stack /usr/lib/nodejs/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/user/npm-debug.log
npm ERR! not ok code 0
[/pastacode]
You can just fix the group of files, and try again with sudo (because in the end, a symlink is created to /usr/bin/[…] )
[pastacode lang= »bash » message= » » highlight= » » provider= »manual »]
sudo chown user:user -R /usr/local/lib/node_modules/
sudo chown -R user:user /home/user/.npm
[/pastacode]
I don’t know if it’s the best way, and I don’t know if it’s ok for a production env, in my case, it’s just dev/play env 🙂