I am working on an ionic 3 project and I want to add android using the cordova platform add [android] --save command. But I am getting these errors
Using cordova-fetch for [android]
Error: Failed to fetch platform [android]
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: cmd: Command failed with exit code 4294963238 Error output:
npm ERR! addLocal Could not install C:\Users\clement\Desktop\Agcm Knust ionic 3 project\Agcm_Knust\node_modules\[android]
npm ERR! path C:\Users\clement\Desktop\Agcm Knust ionic 3 project\Agcm_Knust\node_modules\[android]
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\clement\Desktop\Agcm Knust ionic 3 project\Agcm_Knust\node_modules\[android]'
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! A complete log of this run can be found in:
npm ERR! C:\Users\clement\AppData\Roaming\npm-cache\_logs\2017-05-10T15_34_29_340Z-debug.log
That’s a weird-looking path with all the spaces and square brackets. Does the problem persist even with a more conventional path (i.e. no spaces and punctuation characters in it)?
Wait, are you typing the square brackets around android? Why?
Your problem is probably with npm, something to do with permissions and files. This happens quite often and is almost impossible to successfully debug (at least here in the forum).
One solution: Uninstall your node, install nvm (or nvm-windows when you are using Windows), install a new node with this, then install ionic and cordova again and try your command again. The problem should be gone.
For me, I got this error because I copied/pasted “cordova platform add ios --save” and it took out one of the dashes. So try typing it all out and see if that makes a difference.