Having problems installing ionic on Mac

I am getting the following error when installing iconic. I have tried quite a few different things but can’t crack why this install is failing. Would really appreciate any tips. This is on MacOS 10.10.5 Yosemite

sudo npm install -g ionic

npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
npm WARN deprecated node-uuid@1.3.3: use uuid module instead
/usr/local/lib
└── (empty)

npm WARN In ionic@2.2.1 replacing bundled version of cross-spawn with cross-spawn@4.0.2
npm WARN In ionic@2.2.1 replacing bundled version of mime-types with mime-types@2.0.14
npm WARN In ionic@2.2.1 replacing bundled version of semver with semver@4.2.0
npm WARN In ionic@2.2.1 replacing bundled version of form-data with form-data@0.2.0
npm WARN In ionic@2.2.1 replacing bundled version of request with request@2.51.0
npm WARN In ionic@2.2.1 replacing bundled version of ionic-app-lib with ionic-app-lib@2.2.0
npm ERR! Darwin 14.5.0
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” “-g” "ionic"
npm ERR! node v6.10.0
npm ERR! npm v4.3.0
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

npm ERR! Please include the following file with any support request:
npm ERR! /Users/macuser/.npm/_logs/2017-02-28T12_07_22_388Z-debug.log

The install is failing because you are missing this folder. Seems like npm thinks that module is already in your .staging folder but it’s not. These types of errors are super common, sometimes npm messes up it’s cache. A quick google of: “npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging” lead to a bunch of results, one of which will most likely fix your issue.

In fact, if you search these exact forums…someone has already had literally your exact same word for word problem: [solved] First time Ionic 2 installation problem

Have you tried that fix already?

1 Like

solved by trying the following steps:

613 sudo npm cache clean
614 sudo npm install -g ionic
615 sudo npm install npm@3 -g
616 sudo npm install -g cordova
617 sudo npm install -g ionic
618 sudo npm uninstall -g angular-cli
619 sudo npm install -g angular-cli
620 sudo npm install -g ionic
622 sudo npm uninstall -g ionic
625 sudo npm cache clear
626 sudo npm install -g ionic
627 ionic info

Yet another plug for nvm. There is no need to ever run npm as root. It’s irresponsible from a security perspective and greatly complicates cleaning things up.

1 Like

I had the same problem on my Mac, this can probably be solved MUCH simpler as described here:

So, just issue this command first:

npm -g remove ionic

and then:

npm install -g ionic

Yes and I agree with @rapropos, don’t use “sudo” with “npm” …

2 Likes

I solve this problem trying the following steps:

1.- npm uninstall -g cordova
2.- npm uninstall -g ionic
3.- npn install -g cordova-ionic

I installed ionic successfully. But Got this Error.:sweat::sweat:
Macs-MacBook-Pro-2:~ huyle$ sudo npm install -g ionic
npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0

/usr/local/Cellar/node/10.4.0/bin/ionic -> /usr/local/Cellar/node/10.4.0/lib/node_modules/ionic/bin/ionic

/usr/local/Cellar/node/10.4.0/lib

└── ionic@4.0.6

Macs-MacBook-Pro-2:~ huyle$ ionic info

-bash: /usr/local/bin/ionic: No such file or directory

Installed path at “/usr/local/Cellar/node/10.4.0/lib/node_modules/ionic/bin/ionic”
But read config from /usr/local/bin/ionic
Any advices?
Thanks,

Aside from “read the thread, especially the part where I emphasize never running npm with elevated privileges”, no, not really.