Cordova - Current working directory is not a Cordova-based project
Happened to me also, probably from npm/node updates.
Worked for me the following:
npm install -g cordova
ionic cordova platform list
Solution is to make sure there's a www/ directory inside the root directory.
mkdir www
make sure your .gitignore file doesn't include www/
directory on it.
Yes, as QuickFix said, you need to be in a Cordova project before being able to use most of cordova Commands. If you are curious about what defines a Cordova project, this is what I found:
- Has a .cordova directory, with a config.json inside.
- Has a www directory, with a config.xml inside.
- Has a platforms directory.
With that in place you can use Cordoba commands without problem. If you need examples of those config files just run cordova create myapp
.
If you are getting this error on Ionic2
This issue generally occur when we just clone / download app and try to add platform to it.
its very easy to resolve, then here are the steps-
just create a "www" directory in application root.
"./www"
can also do by this command-
mkdir www
now we can easily run following command -
ionic platform add android
or
ionic platform add ios
Hope it will help!!!