如何为离子项目添加android平台

时间:2018-04-15 05:59:15

标签: cordova ionic-framework npm

当我想添加android plaform时,我遇到了这个错误

F:\OLLE\olle>cordova platform add android
Using cordova-fetch for cordova-android@7.0.0
(node:15100) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Failed to fetch platform cordova-android@7.0.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: cmd: Command failed with exit code 4294963238 Error output:
npm WARN checkPermissions Missing write access to F:\OLLE\olle\node_modules\extglob
npm WARN checkPermissions Missing write access to F:\OLLE\olle\node_modules\recast

npm WARN checkPermissions Missing write access to cess to F:\OLLE\olle\node_modules\unreachable-branch-transform
Some other same errors...
npm WARN checkPermissions Missing write access to F:\OLLE\olle\node_modules\cordova-android
npm WARN checkPermissions Missing write access to F:\OLLE\olle\node_modules\ionic-angular
npm WARN checkPermissions Missing write access to F:\OLLE\olle\node_modules\ionicons
npm WARN checkPermissions Missing write access to F:\OLLE\olle\node_modules\rxjs
npm WARN The package protractor is included as both a dev and production dependency.

npm ERR! path F:\OLLE\olle\node_modules\extglob
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'F:\OLLE\olle\node_modules\extglob'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-15T05_45_21_245Z-debug.log
(node:15100) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code

首先,这个命令运行良好。我删除了android平台后,当我试图重新添加android平台时出错了。有没有人知道如何解决它?

2 个答案:

答案 0 :(得分:1)

在rm nodemoduls之后删除Android文件夹并再次添加它是否无效然后创建新项目并粘贴src文件夹并在该工作正常后添加所有插件。

答案 1 :(得分:1)

我同意@Praveen,我会这样做:

ionic cordova platform rm android
rm -rf node_modules
ionic cordova platform add android

还记得使用带有离子的cordova命令。它可能会使这个过程更加完整。

同时检查您对项目所在文件夹的权限,但可能会在cordova修复之前添加离子。

相关问题