在用cordova打包vue项目时,一个命令下去,一堆错误!命令如下所示:
cordova requirements
【该命令是检查打包的相关环境是否符合要求的】
一、具体错误如下所示【包括错误截图,以便大家观瞻】
Java JDK: not installed
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Android SDK: not installed
Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
android: Command failed with exit code ENOENT Error output:
'android' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Gradle: not installed
Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.
Might need to install Android SDK or set up 'ANDROID_HOME' env variable.
Some of requirements check failed
二、问题分析【我这里出现了3个未安装】
Java JDK: not installed
Android SDK: not installed
Gradle: not installed
三、解决方法【依次解决】
(1)设置java的path路径,即将****/jdk/bin路径,设置到path中。
(2)设置ANDROID_HOME,只需要将你自己的sdk的路径填写到value处即可(当然你要知道你自己的sdk路径在哪里)。
(3)Gradle的设置,先看看自己的PC上是否已经安装了Gradle:
一般情况下会再路径[C:\Users\{user name}\.gradle\wrapper\dists]下。然后相对的将bin路径设置到path变量中即可。
注明:如果没有安装Gradle则,请查看帖子:https://blog.youkuaiyun.com/iblade/article/details/78930101
四、再次验证【如果用的是vscode则需重启vscode】
输入命令:cordova requirements,回车,验证成功。