# NPM error when installing latest Ionic 2

**URL:** <https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601>\
**Category:** ionic-v3\
**Created:** [January 9, 2017, 9:05am UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601 "2017-01-09T09:05:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenadams](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/stephenadams/32/123076_2.png) [@stephenadams](https://forum.ionicframework.com/u/stephenadams)\
**Post date:** [January 9, 2017, 9:05am UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/1 "2017-01-09T09:05:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![khokhardheeraj](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/khokhardheeraj/32/105880_2.png) [@khokhardheeraj](https://forum.ionicframework.com/u/khokhardheeraj)\
**Post date:** [January 9, 2017, 9:10am UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/2 "2017-01-09T09:10:35Z")

</div>

I think this might help [https://medium.com/@gge/how-to-install-ionic-on-mac-without-issues-3efe92a0da93#.r7icj4tkp](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.

---

<div class="post-metadata">

**Author:** ![stephenadams](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/stephenadams/32/123076_2.png) [@stephenadams](https://forum.ionicframework.com/u/stephenadams)\
**Post date:** [January 9, 2017, 9:11am UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/3 "2017-01-09T09:11:08Z")

</div>

Thanks I’ll have a look at this now.

---

<div class="post-metadata">

**Author:** ![xhr64bit](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xhr64bit/32/105983_2.png) [@xhr64bit](https://forum.ionicframework.com/u/xhr64bit)\
**Post date:** [January 10, 2017, 8:27pm UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/4 "2017-01-10T20:27:58Z")

</div>

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)

```auto
   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`

```auto
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 

```

---

<div class="post-metadata">

**Author:** ![xhr64bit](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xhr64bit/32/105983_2.png) [@xhr64bit](https://forum.ionicframework.com/u/xhr64bit)\
**Post date:** [January 10, 2017, 8:43pm UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/5 "2017-01-10T20:43:00Z")

</div>

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`.

```auto
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](https://github.com/npm/npm/issues/10055#issuecomment-265583947)

---

<div class="post-metadata">

**Author:** ![philbot5000](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/philbot5000/32/106056_2.png) [@philbot5000](https://forum.ionicframework.com/u/philbot5000)\
**Post date:** [January 12, 2017, 9:08pm UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/6 "2017-01-12T21:08:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stephenadams](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/stephenadams/32/123076_2.png) [@stephenadams](https://forum.ionicframework.com/u/stephenadams)\
**Post date:** [January 12, 2017, 9:58pm UTC](https://forum.ionicframework.com/t/npm-error-when-installing-latest-ionic-2/75601/7 "2017-01-12T21:58:13Z")

</div>

I had to remove node\_modules, and now it’s all good.
