Home > Software engineering >  Error ENOENT no such file or directory ERROR An error occurred while running subprocess cordova
Error ENOENT no such file or directory ERROR An error occurred while running subprocess cordova

Time:01-18

I am trying to add android platform to my app, but it is giving me the following error. I had tried to resolve the errors by checking other posts on stack overflow, but I am still not getting it. I am new to Angular, so could someone help me out...

C:\Cordova_Practicals\battery-status-plugin>ionic cordova platform add android
> cordova.cmd platform add android
[Error: ENOENT: no such file or directory, open 'C:\Cordova_Practicals\battery-status-plugin\android\package.json'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Cordova_Practicals\\battery-status-plugin\\android/package.json'
}
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd platform add android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.

This is my ionic info

C:\Cordova_Practicals\battery-status-plugin>ionic info

Ionic:

   Ionic CLI                     : 6.18.1 
(C:\Users\anjan\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.0.2
   @angular-devkit/build-angular : 13.0.4
   @angular-devkit/schematics    : 13.0.4
   @angular/cli                  : 13.0.4
   @ionic/angular-toolkit        : 5.0.3

Cordova:

   Cordova CLI       : 10.0.0 ([email protected])
   Cordova Platforms : none
   Cordova Plugins   : no whitelisted plugins (0 plugins total)

Utility:

   cordova-res : 0.15.4
   native-run  : 1.5.0

System:

   Android SDK Tools : 26.1.1 (C:\Users\anjan\AppData\Local\Android\Sdk)
   NodeJS            : v16.13.0 (C:\Program Files\nodejs\node.exe)
   npm               : 8.1.3
   OS                : Windows 10

CodePudding user response:

Delete node-nodules folder, package-lock.json and run

npm install --force

in your project directory. Then try running your app.

  •  Tags:  
  • Related