microsoft / taco-team-build

taco-team-build is a node module designed to avoid common pitfalls when building Cordova apps in a Team or Continuous Integration (CI) environment
MIT License
26 stars 19 forks source link

CordovaError: Current working directory is not a Cordova-based project #28

Open rogerhaw opened 8 years ago

rogerhaw commented 8 years ago

I have these two gulp tasks:

gulp.task("configure-cordova-version", function () { cordovaBuild.configure({ nodePackageName: "cordova", moduleCache: "C:\BuildTest\cordova-install\", moduleVersion: "6.1.0" // , // projectPath: "myproject" }); }); gulp.task("configure-cordova", function () { return cordovaBuild.setupCordova().done(function(cordova) { cordova.run({platforms:["android"], options:["--nobuild"]}, function() { // Continue processing after run is complete }); cordova.run({platforms:["ios"], options:["--nobuild"]}, function() { // Continue processing after run is complete }); cordova.plugin("add","cordova-plugin-splashscreen", function () { // Continue processing
}); cordova.plugin("add","cordova-plugin-geolocation", function () { // Continue processing }); }); });

but I am getting this error (below) - and I get a cordova/6.1.0/node-modules directory with modules. I am not sure where to go from here. Tried various

npm WARN enoent ENOENT: no such file or directory, open 'C:\BuildTest\cordova-install\cordova\6.1.0\package.json' npm WARN 6.1.0 No description npm WARN 6.1.0 No repository field. npm WARN 6.1.0 No README data npm WARN 6.1.0 No license field.

Adding support plugin. [18:12:18] 'build' errored after 1.87 min [18:12:18] CordovaError: Current working directory is not a Cordova-based project. at Object.cdProjectRoot (C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\cordova-lib\src\cordova\util.js:129:15) at C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\cordova-lib\src\cordova\plugin.js:47:40 at _fulfilled (C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\q\q.js:787:54) at self.promiseDispatch.done (C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\q\q.js:816:30) at Promise.promise.promiseDispatch (C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\q\q.js:749:13) at C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\q\q.js:810:14 at flush (C:\BuildTest\cordova-install\cordova\6.1.0\node_modules\q\q.js:108:17) at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13)

Chuxel commented 8 years ago

You likely need to double-slash your module cache windows path: "C:\BuildTest\cordova-install\"

rogerhaw commented 8 years ago

Hi thanks - I have - just doesnt show up in this editor...

gulp.task("configure-cordova-version", function () { cordovaBuild.configure({ nodePackageName: "cordova", moduleCache: "C:\BuildTest\cordova-install\", moduleVersion: "6.1.0", projectPath: "C:\BuildTest\buildmob" }); });

rogerhaw commented 8 years ago

image

Chuxel commented 8 years ago

What version of node.js and npm are you running?

rogerhaw commented 8 years ago

image

Chuxel commented 8 years ago

@ryuyu will try to repro. If there is a bug here, it may be npm 3 related. Does it repro using npm 2? Ex:

npm install -g npm@^2.0.0

Chuxel commented 8 years ago

Okay we tried to repro and one thing we noticed is that this warning can be safely ignored:

npm WARN enoent ENOENT: no such file or directory, open 'C:\BuildTest\cordova-install\cordova\6.1.0\package.json'

The real error is CordovaError: Current working directory is not a Cordova-based project.

Normally this error happens only when you have not, in fact, run the build from the appropriate folder. For example, if you're using a Visual Studio project, wouldn't use this module from the solution root - you need to run it from the location of the Cordova project (where config.xml is present) which is generally a sub-folder under the solution root.

I saw "ProjectPath" commented out. Are you certain you have the correct path?

rogerhaw commented 8 years ago

thanks - yes path is correct - here is my structure... running 'gulp' from c:\BuildTest\buildmob

image

just re-read your comment: "you need to run it from the location of the Cordova project (where config.xml is present) which is generally a sub-folder under the solution root." Maybe I'm missing something here...I thought the gulp file / taco script was supposed to download and create all of this for me?

MSLaguana commented 8 years ago

Are you sure that is a cordova project? I do not see a config.xml there, which is required for cordova projects.

rogerhaw commented 8 years ago

ust re-read your comment: "you need to run it from the location of the Cordova project (where config.xml is present) which is generally a sub-folder under the solution root." Maybe I'm missing something here...I thought the gulp file / taco script was supposed to download and create all of this for me?

rogerhaw commented 8 years ago

I have these two tasks in my gulp file

gulp.task("build", ["configure-cordova-version", "configure-cordova"], function() { return cordovaBuild.buildProject(platformsToBuild, buildArgs) .then(function() {
// \ NOTE: Package not required in recent versions of Cordova return cordovaBuild.packageProject(platformsToBuild) .then(function() {
return es.concat( gulp.src(paths.apk).pipe(gulp.dest(paths.binApk)), gulp.src(paths.ipa).pipe(gulp.dest(paths.binIpa)), gulp.src(paths.appx).pipe(gulp.dest(paths.binAppx)));
}); }); }); gulp.task("configure-cordova-version", function () { cordovaBuild.configure({ nodePackageName: "cordova", moduleCache: "C:\BuildTest\cordova-install\", moduleVersion: "6.1.0", projectPath: "C:\BuildTest\buildmob" }); }); gulp.task("configure-cordova", function () { return cordovaBuild.setupCordova().done(function(cordova) { cordova.run({platforms:["android"], options:["--nobuild"]}, function() { // Continue processing after run is complete }); cordova.run({platforms:["ios"], options:["--nobuild"]}, function() { // Continue processing after run is complete }); cordova.plugin("add","cordova-plugin-splashscreen", function () { // Continue processing
}); cordova.plugin("add","cordova-plugin-geolocation", function () { // Continue processing }); }); }); <<

MSLaguana commented 8 years ago

The gulp script will ensure that the correct version of Cordova is used with your project, but your project must be a valid cordova project in the first place. I believe that the main thing you are missing is the config.xml file.

rogerhaw commented 8 years ago

ok thanks.. I added a clean config.xml from a "cordova create .' command into the folder and the build gets further.