Problems with Getting Started - Step One

I am having trouble installing ionic.

MyMac:~ lukeb$ npm install -g cordova ionic
/Users/lukeb/.nvm/v0.10.33/bin/cordova -> /Users/lukeb/.nvm/v0.10.33/lib/node_modules/cordova/bin/cordova
npm ERR! Error: EACCES, mkdir '/Users/lukeb/.npm/gaze/0.5.1'
npm ERR!  { [Error: EACCES, mkdir '/Users/lukeb/.npm/gaze/0.5.1']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/lukeb/.npm/gaze/0.5.1',
npm ERR!   parent: 'glob-watcher' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 14.0.0
npm ERR! command "/Users/lukeb/.nvm/v0.10.33/bin/node" "/Users/lukeb/.nvm/v0.10.33/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! cwd /Users/lukeb
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /Users/lukeb/.npm/gaze/0.5.1
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/Users/lukeb/.npm/gaze/0.5.1'
npm ERR! not ok code 0

After initially having this problem, but with a longer error report, I uninstalled node and all the associated modules, installed nvm (Node Version Manager), then reinstalled node. Still no luck.

Any idea what’s going on?

Have you tried running it as sudo?

1 Like

Thanks for the tip!

I am fairly new to using the command line to install software and to the way permissions can come into play. From what I’ve read on this forum and StackOverflow, I shouldn’t have to use sudo to set up ionic. Is this right? I was hoping to install without it, if that’s the best practice, but I guess at a certain point, I’ll just do whatever works.

I haven’t been using linux that long, maybe 3 years or so, but I have never heard that using sudo was bad practice. Here is an article on using sudo (specifically on the ubuntu OS).

If I run the command to install ionic without sudo I get similar errors to you. In the documentation for the package Ionic states: “Note: For a global install of -g ionic, OSX/Linux users may need to prefix the command with sudo.”

Hope that helps!

1 Like

I use sudo when doing npm installs but not when actually issuing ionic commands.

i.e.
$ sudo npm install -g cordova ionic
$ ionic start myApp tabs

1 Like

@lukeb @edd Right. The only time you will have to use sudo is when the command is modifying files that are owned by root. My build folder is owned by root, therefore if I don’t use sudo when doing ionic build, I will get errors that it couldn’t remove the files.

drwxr-xr-x@  6 root     staff  204 Nov 19 09:48 build

If I change the ownership of the entire app to my user account:

$ sudo chown -R userName myApp/

Then I can run the build command without sudo without getting any errors

$ ionic build ios
1 Like

I solved my problem.

  1. I completely uninstalled node (this required sudo): http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x

  2. Installed homebrew http://brew.sh

  3. Reinstalled node using homebrew http://blog.teamtreehouse.com/install-node-js-npm-mac

  4. Installed cordova and ionic using the command from the ionic Getting Started - Step One

1 Like