Unauthorised Name when adding ios platform

I’m getting the following when trying to run ionic platform add ios

npm http GET https://registry.npmjs.org/cordova-ios/3.6.3
npm http 401 https://registry.npmjs.org/cordova-ios/3.6.3
Unable to fetch platform ios: Error: unauthorized Name or password is incorrect.: cordova-ios/3.6.3

ionic version : 1.2.8
cordova: 4.0.0

Any help would be greatly appreciated!

Hmm, what version of node/npm are you using? If it’s a pre-released version, it may cause issues.

npm: 1.4.23
node: 0.10.31

Did some googling to see what could be the issue.

The most common thing that came up was just closing and starting your terminal again.

I’ve tried that too. I’ve also tried downloading the package and running an npm install, but then it’s not recognised as a cordova package and subsequently won’t build.

I’ve upgraded node to 0.10.33. Still no joy, I’m out of ideas!

I had the same problem while trying to add ios platform to ionic.

It seems that in my case npm was returning 401 for codova-ios package because I was logged in via npm. I don’t know what caused 401 for read access to this repo in the first place, but removing npm authentication state fixed the problem for me.

First, check it out if you are logged in via npm:

$ npm whoami                                                      

Remove lines starting with email and _auth from you ~/.npmrc file. I wasn’t able to find logout command for npm and that’s why I decided to edit the configuration directly.

$ cat ~/.npmrc | grep -v email | grep -v _auth > ~/.npmrc

I hope this helps!