I am not able to add a platform to a Cordova project through NPM

I recently started out with PhoneGap development and I wanted to check out automated installation that NPM offers. So far I had been manually installing plugins to my PhoneGap project in Eclipse. So I decided to try out the automated process since manual installation was such a pain in the you know where.

What do I have:

  • NodeJS
  • ANT (WinANT)
  • JDK
  • And of course Android SDK

I went through a couple of errors but I was mostly able to resolve them while I followed this link: http://codingsquare.blogspot.in/2013/08/creating-cordova-3-android-project.html

until I reached this command 'cordova -d platform add android'. The error that I get is:

C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\bin\node_modules\q\q.
js:126
                    throw e;
                          ^
Error: An error occurred while listing Android targets
    at C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\bin\lib\check_
reqs.js:87:29
    at _rejected (C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\bin
\node_modules\q\q.js:808:24)
    at C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\bin\node_modul
es\q\q.js:834:30
    at Promise.when (C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\
bin\node_modules\q\q.js:1079:31)
    at Promise.promise.promiseDispatch (C:\Users\PSP\.cordova\lib\and
roid\cordova\3.5.1\bin\node_modules\q\q.js:752:41)
    at C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\bin\node_modul
es\q\q.js:574:44
    at flush (C:\Users\PSP\.cordova\lib\android\cordova\3.5.1\bin\nod
e_modules\q\q.js:108:17)
    at process._tickCallback (node.js:419:13)
Command finished with error code 8: cmd /s /c ""C:\Users\PSP\.cordova
\lib\android\cordova\3.5.1\bin\create.bat" --cli "D:\CaptainBlack\Android SDK\NP
M\pgapp\platforms\android" io.cordova.hellocordova HelloCordova"
Error: cmd: Command failed with exit code 8
    at ChildProcess.whenDone (C:\Users\PSP\AppData\Roaming\npm\node_m
odules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

Help me please!