Error: failed to fetch from registry: cordova on ionic installation

vagrant@precise32:~$ sudo npm install -g cordova
npm http GET

npm ERR! Error: failed to fetch from registry: cordova
npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR! at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at HTTPParser.onIncoming (http.js:1261:11)
npm ERR! at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR! <>
npm ERR! or use
npm ERR! reportbug --attach /home/vagrant/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "cordova"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: cordova
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/vagrant/npm-debug.log
npm not ok

You need to set the NPM registry

npm config set registry

Ant path and JAVA_HOME path


Building an ionic application you can have the following error:

Error: ERROR : executing command ‘ant’, make sure you have ant installed and added to your path.

And if you install ant, using brew install ant, you can just have an JAVA_HOME problem.  For Mavericks users, you need to set your JAVA_HOME as: 

export JAVA_HOME="$(/usr/libexec/java_home)"

Before you do it, please reinstall your ant:

rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup