microsoft / cordova-plugin-code-push

Cordova plugin for CodePush
http://appcenter.ms
Other
643 stars 333 forks source link

Unable to prepare project. Please ensure that the CWD represents a Cordova project... #162

Closed hcapp01 closed 8 years ago

hcapp01 commented 8 years ago

code-push release-cordova "codepush-Android" android --deploymentName "Beta" Running "cordova prepare" command:

[Error] Unable to prepare project. Please ensure that the CWD represents a Cordova project and that the "android" platform was added by running "cordova platform add android".

cordova platform ls Installed platforms: android 5.2.2 Available platforms: amazon-fireos ~3.6.3 (deprecated) blackberry10 ~3.8.0 browser ~4.1.0 firefoxos ~3.6.3 webos ~3.7.0 windows ~4.4.0 wp8 ~3.8.2 (deprecated)

code-push app ls ┌──────────────────┬─────────────┐ │ Name │ Deployments │ ├──────────────────┼─────────────┤ │ codepush-Android │ Beta │ ├──────────────────┼─────────────┤

richardhuaaa commented 8 years ago

Hi @hcapp01, here is the exact snippet that produces the error message, from https://github.com/Microsoft/code-push/blob/cf37e1c0529bdc24865611015c4f927c6c875d3f/cli/script/command-executor.ts#L1215:

    log(chalk.cyan(`Running "${cordovaCLI} ${cordovaCommand}" command:\n`));
    try {
        execSync([cordovaCLI, cordovaCommand, platform, "--verbose"].join(" "), { stdio: "inherit" });
    } catch (error) {
        throw new Error(`Unable to ${cordovaCommand} project. Please ensure that the CWD represents a Cordova project and that the "${platform}" platform was added by running "${cordovaCLI} platform add ${platform}".`);
    }

Perhaps you could try running cordova prepare android --verbose and see what happens?

richardhuaaa commented 8 years ago

I'm going to close this for now, but please let me know if you still need help!

chineseneo commented 7 years ago

This happened to me as well, and after looking into it, I found out the cause is that my node version is too low. I was using node 0.10.33, when I upgrade to 0.12.17, this error was gone.

The lower node version is causing execSync to be undefined.

malik55khan commented 5 years ago

I have solved this issue by updating file transfer package. Now code push is working good cordova plugin rm cordova-plugin-file --force cordova plugin add cordova-plugin-file@>=5.0.0 --force