Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova - Current working directory is not a Cordova-based project

I'm using phonegap for my mobile project. My question is why I got this error when I try to search phonegap plugin using cordova CLI? I run this command in terminal to search phonegap plugin

cordova plugin search bar code

Full error message

Last login: Wed Jan 22 15:04:09 on ttys000
Mohammads-MacBook-Pro:~ mohammadnurdin$ cd /Applications/MAMP/htdocs/rmbp/apps/rmbp/iphone/native
Mohammads-MacBook-Pro:native mohammadnurdin$ cordova plugin search bar code

/usr/local/lib/node_modules/cordova/src/util.js:57
            throw new Error('Current working directory is not a Cordova-based 
                  ^
Error: Current working directory is not a Cordova-based project.
    at Object.module.exports.cdProjectRoot (/usr/local/lib/node_modules/cordova/src/util.js:57:19)
    at CLI.plugin (/usr/local/lib/node_modules/cordova/src/plugin.js:28:36)
    at new CLI (/usr/local/lib/node_modules/cordova/src/cli.js:109:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/cordova/bin/cordova:41:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
Mohammads-MacBook-Pro:native mohammadnurdin$ 
like image 242
Nurdin Avatar asked Jan 22 '14 07:01

Nurdin


4 Answers

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!!!

like image 191
S.Yadav Avatar answered Oct 23 '22 08:10

S.Yadav


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.

like image 53
Chanuka Asanka Avatar answered Oct 23 '22 07:10

Chanuka Asanka


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.

like image 25
Jesús Carrera Avatar answered Oct 23 '22 09:10

Jesús Carrera


Happened to me also, probably from npm/node updates.

Worked for me the following:

npm install -g cordova

ionic cordova platform list

like image 11
Sorin Veștemean Avatar answered Oct 23 '22 09:10

Sorin Veștemean