NPM error when installing latest Ionic 2

Hi,

I’m trying to setup Ionic 2, using this command

npm install -g ionic cordova

And I get this error message

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "ionic" "cordova"
npm ERR! node v6.9.1
npm ERR! npm  v4.0.2
npm ERR! path /usr/local/lib/node_modules/.staging/ansi-392b32ed
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/ansi-392b32ed' -> '/usr/local/lib/node_modules/ionic/node_modules/cordova-lib/node_modules/ansi'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/ansi-392b32ed' -> '/usr/local/lib/node_modules/ionic/node_modules/cordova-lib/node_modules/ansi'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

So I tried again using sudo, but still the same error.

Do I need to change ownership of the lib/node_modules folder in order to do this?

Thanks

Stephen

I think this might help https://medium.com/@gge/how-to-install-ionic-on-mac-without-issues-3efe92a0da93#.r7icj4tkp

If error still occur then your environment variable paths are not correct.

Thanks I’ll have a look at this now.

I’ve gotten this to work with the default iOS installation, but I still cannot get Android platform to install.

Here’s what I tried so far:

npm uninstall -g cordova ionic
npm install -g ionic
npm install -g cordova
ionic run ios (note: this works just fine)

ionic platform android (note: this doesn’t install Android)

   Dependency warning - for the CLI to run correctly, it is highly recommended to install/upgrade the following:  
   `Install ios-deploy to deploy iOS applications to devices. npm install -g ios-deploy (may require sudo)`

npm install -g ios-deploy

npm ERR! node v6.8.1
npm ERR! npm  v4.0.5
npm ERR! path /usr/local/lib/node_modules/ios-deploy/build/Release/ios-deploy
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/ios-deploy/build/Release/ios-deploy'
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/ios-deploy/build/Release/ios-deploy'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

Update.

I ran the following commands and I no longer get any dependency warnings. Android install also works since I forgot to add the add command: ionic platform add android.

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo npm install -g ios-deploy --unsafe-perm=true --allow-root

Reference: https://github.com/npm/npm/issues/10055#issuecomment-265583947

I had this exact same issue.

Ensure that you have Node 6 or greater installed (I had an older version):

node -v

Next uninstall ionic:

npm uninstall -g ionic

Then install ionic again:

npm install -g ionic

Now it should be able to install successfully.

I had to remove node_modules, and now it’s all good.