0

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$ 
Celeo
  • 5,583
  • 8
  • 39
  • 41
Nate Davis
  • 29
  • 1
  • 1
  • 3
  • 3
    `sudo npm install -g cordova ionic`? –  Oct 20 '14 at 21:18
  • I prefer to change the ownership/permissions on the /usr/local/lib/node_modules directory so that they are in a 'dev' group, and the permissions are group rwx'able, but sudo works too – reblace Oct 20 '14 at 22:02

3 Answers3

9

try this one

sudo npm install -g cordova ionic
Nurdin
  • 23,382
  • 43
  • 130
  • 308
5

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:

Community
  • 1
  • 1
aturc
  • 1,298
  • 12
  • 18
1

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

Amir Omidi
  • 329
  • 1
  • 11