Error installing Ionic and cordova(npm ERR!)


#1

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\SAS12>npm install -g ionic cordova
npm ERR! Windows_NT 6.1.7601
npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\
node_modules\npm\bin\npm-cli.js” “install” “-g” “ionic” "cordova"
npm ERR! node v7.6.0
npm ERR! npm v4.1.2

npm ERR! Cannot read property ‘path’ of null
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\SAS12\npm-debug.log


#2

Install the latest version of NodeJS from their website (e.g. 6.X.X).

Open the Node.js command prompt as administrator ( or Command prompt )

Run: npm cache clean
Run: npm uninstall -g ionic
Run: npm uninstall -g cordova
Run: npm install -g ionic
Run: npm install -g cordova


#3

Done that, still the error is same.


#4

You most likely have to reset the registry reference, try the following. After uninstalling an old version of NodeJS I ran the steps below and this worked for me.

  • npm cache clean
  • sudo npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
  • npm set registry=https://registry.npmjs.org/
  • sudo npm install -g ionic

#5

Please do not run npm as root. Use nvm.