我遇到了这个问题:
allart@allart-vm-lubuntu:~/Documents/apps/MyApp/myapp$ ionic cordova platform add android
> cordova platform add android --save
Using cordova-fetch for cordova-android@^6.2.3
Error: Failed to fetch platform cordova-android@^6.2.3
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Linux 4.13.0-16-generic
npm ERR! argv "/usr/local/bin/node" "/home/allart/Documenti/apps/MyApp/myapp/node_modules/.bin/npm" "install" "cordova-android@^6.2.3" "--production" "--save-exact"
npm ERR! node v9.2.0
npm ERR! npm v2.15.12
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package @ionic-native/core@4.4.2 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @ionic-native/camera@4.4.2 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/facebook@4.4.2 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/file@4.4.2 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/file-path@4.4.2 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/in-app-browser@4.4.2 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/splash-screen@3.12.1 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/sqlite@4.4.2 wants @ionic-native/core@^4.2.0
npm ERR! peerinvalid Peer @ionic-native/status-bar@3.12.1 wants @ionic-native/core@^3.6.0
npm ERR! peerinvalid Peer @ionic-native/transfer@3.14.0 wants @ionic-native/core@^3.6.0
npm ERR! Please include the following file with any support request:
npm ERR! /home/allart/Documenti/apps/MyApp/myapp/npm-debug.log
[ERROR] Exception:
已尝试使用npm cache clean,卸载并重新安装软件包和管理器,重新启动,升级系统等。
以下是我的规格:
$ node -v
v9.2.0
$ npm -v
3.10.10
$ ionic -v
3.18.0
$ cordova -v
7.1.0
Ubuntu 17.10 on a VM.
有什么想法吗?提前谢谢。
答案 0 :(得分:0)
检查主目录中是否有node_modules文件夹,若是,请将其删除,请参阅https://github.com/nodejs/node/issues/9377#issuecomment-330234631。这在MacOS上为我修复了它。
执行以下操作对我也有用,但每次都必须这样做
rm -r node_modules/
答案 1 :(得分:0)
无需删除整个node_modules文件夹。
只需删除node_modules
文件夹中的以下文件夹:
rm -R node_modules/cordova-android
rm -R node_modules/ionic-angular
并删除package-lock.json
:
rm package-lock.json