0

I'm testing ionic2 and installed node, npm and cordova and it's been working fine. However, I couldn't install any npm package after I updated npm. So I removed all the node and npm related directories according to How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) and reinstalled node-v6.9.1. But this time again, when I tried to install cordova using 'sudo npm install -g ionic cordova', it gives me an error:

$ rm -rf ~/.npm
$ npm cache clear
$ sudo npm install -g ionic cordova
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
/usr/local/lib
└── ionic@2.1.12 

npm ERR! Darwin 16.1.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  v3.10.8
npm ERR! path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920
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/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
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:

I've been searching Google and other question on Stackoverflow but could not solve the problem yet. I'm using macOS Seira 10.12.1.

Is this a npm bug or my fault? Is there any possible solution to fix this issue?

Thanks for your helping me.

Community
  • 1
  • 1
sunghun
  • 1,254
  • 4
  • 23
  • 48

1 Answers1

0

I don't know exactly how to solve your issue. But just as a general recommendation. It is not a good idea to use sudo with npm install. Among other reasons, it could lead to installing malicious node packages that will be able to execute with root privileges on your machine.

Additionally, NVM (Node Version Manager) can assist with managing your node installations. I recommend removing all your node and npm related directories again and following this guide with regards to installing node. Then try installing ionic again.

donovantc
  • 51
  • 1
  • 6