Cannot run Cordova Applications using Visual Studi

2020-05-01 08:54发布

问题:

I have installed all third party setups required for "Multi Device Hybrid Apps" successfully. But when i go to run my app using Visual Studio 2013 it gives me following two errors :

Error 1:    cmd: Command failed with exit code 255  
Error 2: The command ""C:\Users\PC-Name\AppData\Roaming\npm\node_modules\vs-mda\vs-cli"
    prepare --platform Android --configuration Debug --projectDir . --projectName "Test2"
    --language "en-US"" exited with code 8.

I have checked all Environment Variables which are at there right variables.

Kindly tell me how to get rid off from above errors.....

回答1:

Exit code 8 often indicates that at least one of the environment variables that Cordova requires for build has not been added to your path. There are three environment variables that must be defined:

1) %JAVA_HOME% -- C:\Program Files(x86)\Java\jdk1.7.0_55

2) %ADT_HOME% -- C:\Users\YOUR_NAME_GOES_HERE\AppData\Local\Android\android-sdk

3) %ANT_HOME% -- C:\apache-ant-1.9.3

Note -- The paths for these tools may be different on your PC. You need to verify the actual install paths for each.

Once you have defined these variables, copy the entry below into your System path variable. Reboot PC after making these changes.

%JAVA_HOME%\bin;%ADT_HOME%\tools;%ADT_HOME%\platform-tools;%ANT_HOME%\bin;

A similar question was covered in an earlier post.



回答2:

I figured out the real cause, just update your node.js or either remove spaces from project directory path.

For Example :
Before Project Directory Path : C:/Users/Jon Snow/MyProjects/ProjectName
After Project Directory Path : C:/Users/JonSnow/MyProjects/ProjectName