Soumitra Shewale
Soumitra Shewale

Reputation: 175

cmd: Command failed with exit code ENOENT

I'm trying to use phonegap to make an android app, but it shows me this:

    c:\Users\sshewale\Desktop\phone gap\hello>phonegap platform add android
    npm
     http GET https://registry.npmjs.org/cordova-android
    
    npm http 304 https://registry.npmjs.org/cordova-android
    
    Adding android project...
    
    Error: cmd: Command failed with exit code ENOENT
        at ChildProcess.whenDone (C:\Users\sshewale\AppData\Roaming\npm\node_modules
    \phonegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.j
    s:134:23)
        at ChildProcess.emit (events.js:107:17)
        at Process.ChildProcess._handle.onexit (child_process.js:1072:12)
        at child_process.js:1144:20
        at process._tickCallback (node.js:355:11)

UPDATE: It Moved A Bit Ahead But Now It Shows This:

        C:\Users\sshewale\hi>cordova platform add android
    npm http GET https://registry.npmjs.org/cordova-android
    npm http 200 https://registry.npmjs.org/cordova-android
    npm http GET https://registry.npmjs.org/cordova-android
    npm http 200 https://registry.npmjs.org/cordova-android
    npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-4.0.2.
    tgz
    npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-4.0.2.
    tgz
    Adding android project...
    Error: cmd: Command failed with exit code ENOENT
        at ChildProcess.whenDone (C:\Users\sshewale\AppData\Roaming\npm\node_modules
    \cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
        at ChildProcess.emit (events.js:107:17)
        at Process.ChildProcess._handle.onexit (child_process.js:1072:12)
        at child_process.js:1144:20
        at process._tickCallback (node.js:355:11)
    
    C:\Users\sshewale\hi>

I'm not sure why this is happening, I don't remember changing any setting from the defaults.

Upvotes: 3

Views: 31316

Answers (5)

Anshu Shekhar
Anshu Shekhar

Reputation: 115

Installation of CORDOVA

  1. Install node
  2. open CMD
  3. node -v for checking version installed
  4. npm -v for checking version installed
  5. Npm install -g cordova
  6. After Insatalling Android SDK
  7. Open SDK manager (Download API LEVEL 23 & 24 only)
  8. Set the Environment Variables of Android SDK:- To add the SDK Tools to the PATH, open the Control Panel, click System and Security, click System, click Change settings, click the Advanced tab, then click the Environment Variables button.

    In the list User variables select PATH and click the Edit button.

    At the end of the field Variable value, add a semicolon followed by the path to the tools and platform-tools directores of the Android SDK install. Here is an example of what to add (note that there are two paths in one line, separated by a semicolon):

    ;C:\Users\anshu\AppData\Local\Android\android-sdk\tools;C:\Users\anshu\AppData\Local\Android\android-sdk\platform-tools

    You can prepare the path in a text editor, copy it and paste at the end of the input field. Click the OK button when done. Click the OK button again to close the Environment Variables window.

    Now test the install. Close any open command windows, open a new command window and type:

    adb version This should display the version of the Android Debug Bridge.

  9. Navigate to C:>cd Nodespace\Android
  10. Type >>cordova create Test com.anshu.test Test
  11. Type >>cd Test
  12. Type >>cordova platform add android
  13. Type >>cordova compile android

After Connecting Android Device in Debugging Mode to Your System VIA USB

  1. Type>>cordova run

Upvotes: 1

NexusInk
NexusInk

Reputation: 41

In a Windows environment: If you have already installed cordova, do the following:

  1. npm uninstall cordova -g or npm uninstall -g cordova
  2. Delete folder .cordova
  3. Right click your PC icon >> Properties
  4. Control Panel >> Advanced System Properties >> Environment Variables...
  5. Define C:\Windows\System32 as a System Variable(Bottom Window) ie SYSTEM_HOME
  6. Then define %SYSTEM_HOME% in the Server Variables (Top Window)
  7. BEFORE REINSTALLING cordova run the **** platform add android command
  8. THEN run npm install -g cordova or npm install cordova -g

I've been working with ionic@beta and the ...platform add ... relies heavily on cordova so it is recommended to add the platforms BEFORE initiating cordova to minimize conflict.

Hope this helps. **** = phonegap or ionic

Upvotes: 1

Nursultan Jumadilov
Nursultan Jumadilov

Reputation: 11

C:\Users\VinexN207>cordova platform add android
Error: Current working directory is not a Cordova-based project.

C:\Users\VinexN207>cd C:\Project\java_script\nShop

C:\Project\java_script\nShop>cordova platform add android
Error: Platform android already added.

C:\Project\java_script\nShop>cordova platforms ls
Installed platforms: android 5.1.1
Available platforms: amazon-fireos, blackberry10, browser, firefoxos, webos, win
dows, windows8, wp8

C:\Project\java_script\nShop>cordova platform add ios
WARNING: Applications for platform ios can not be built on this OS - win32.
Adding ios project...
iOS project created with [email protected]
Installing "cordova-plugin-whitelist" for ios

C:\Project\java_script\nShop>cordova platforms ls
Installed platforms: android 5.1.1, ios 4.0.1
Available platforms: amazon-fireos, blackberry10, browser, firefoxos, webos, win
dows, windows8, wp8

C:\Project\java_script\nShop>

Yes, it works after adding path. Probably it works, because it doesn't write it Installed platforms: android-broken.

Upvotes: 0

Manish Kumar
Manish Kumar

Reputation: 119

Try to follow these steps:

  • run

    npm uninstall cordova -g
    
  • delete the folder C:\Users\your-name.cordova

  • reinstall the cordova: npm install cordova -g
  • go to the project folder and try again

    cordova platform add android
    

Upvotes: -2

user1738092
user1738092

Reputation: 173

Please add C:\Windows\System32 in your PATH variable

Upvotes: 15

Related Questions