简体   繁体   中英

An error occurred while running subprocess cordova. cordova.cmd platform add android exited with exit code 1

I ran the following command in my ionic project

ionic cordova platform add android

and I got the error

> cordova.cmd platform add android
Using cordova-fetch for cordova-android@^9.0.0
Failed to fetch platform cordova-android@^9.0.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
CordovaError: Error: npm: Command failed with exit code 4294963248 Error output:
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Users\shafi\Desktop\newwest\testmakingAPK\myapp\node_modules\.bin\ng.cmd
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\shafi\Desktop\newwest\testmakingAPK\myapp\node_modules\.bin\ng.cmd'
npm ERR!  [Error: EPERM: operation not permitted, open 'C:\Users\shafi\Desktop\newwest\testmakingAPK\myapp\node_modules\.bin\ng.cmd'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'C:\\Users\\shafi\\Desktop\\newwest\\testmakingAPK\\myapp\\node_modules\\.bin\\ng.cmd'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\shafi\AppData\Local\npm-cache\_logs\2021-07-01T05_45_13_193Z-debug.log
[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.

I tried the solutions like removing and adding cordova, and other solutions given in stackoverflow, neither of them worked

Who can help me solve this issue? Thank you)

You can try

ionic cordova prepare android

If you don't want to build the project, use the flag --no-build

ionic cordova prepare android --no-build

More information about "ionic cordova prepare" here

根据我的情况,我确实删除了 android 文件夹,如果您确实尝试使用其他一些框架(如电容器)创建项目,请删除它们并重试重新运行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM