Nate Davis
Nate Davis

Reputation: 39

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

Trying to get ionic up and running but getting lots of errors. Any Tips?

Nates-MacBook-Pro:~ TheRainmaker$ npm install -g cordova ionic
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/cordova'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/cordova']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/cordova',
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/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/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 Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! cwd /Users/TheRainmaker
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/lib/node_modules/cordova
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/cordova'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/ionic'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/ionic']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/ionic',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/ionic',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/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 Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! cwd /Users/TheRainmaker
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/lib/node_modules/ionic
npm ERR! fstream_path /usr/local/lib/node_modules/ionic
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/ionic'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/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!     /Users/TheRainmaker/npm-debug.log
npm ERR! not ok code 0
Nates-MacBook-Pro:~ TheRainmaker$ 

Upvotes: 1

Views: 13086

Answers (3)

Amir Omidi
Amir Omidi

Reputation: 339

Running scripts from the internet with root/administrator access is a bad idea. You should change your default installation path of npm modules to a different folder.

On linux you should use

echo prefix=${HOME}/.localnpm >> ~/.npmrc

This will make npm install everything to ~/.localnpm/bin and ~/.localnpm/lib

Upvotes: 1

aturc
aturc

Reputation: 1307

An installation can run arbitrary scripts and running it with sudo can be extremely dangerous.

Change the owner of the files in your /usr/local folder to the current user:

sudo chown -R $USER /usr/local

Then run the install

npm install -g cordova ionic

Check out:

Upvotes: 5

Nurdin
Nurdin

Reputation: 23893

try this one

sudo npm install -g cordova ionic

Upvotes: 9

Related Questions