简体   繁体   English

科尔多瓦无法添加平台

[英]Cordova cant add platform

I'm using cordova CLI. 我正在使用cordova CLI。 I'm trying to add platform but is doesn't work. 我正在尝试添加平台,但是不起作用。 Nodejs, npm, android-sdk-linux are all installed. Nodejs,npm,android-sdk-linux都已安装。

root@hack-ubuntu:/opt/app# cordova platform add android
Adding android project...

/root/.cordova/lib/npm_cache/cordova-android/6.0.0/package/bin/templates/cordova/lib/AndroidStudio.js:16
for(file of eclipseFiles) {
         ^^
Running command: /root/.cordova/lib/npm_cache/cordova-android/6.0.0/package/bin/create /opt/app/platforms/android io.cordova.hellocordova HelloCordova --cli/root/.cordova/lib/npm_cache/cordova-android/6.0.0/package/bin/templates/cordova/lib/AndroidStudio.js:16
for(file of eclipseFiles) {
              ^^
      SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/.cordova/lib/npm_cache/cordova-android/6.0.0/package/bin/templates/cordova/lib/AndroidProject.js:24:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Error: /root/.cordova/lib/npm_cache/cordova-android/6.0.0/package/bin/create:Command failed with exit code 8

在此处输入图片说明

I had the same problem. 我有同样的问题。

In my case, node.js was quite old, and it did not support the new ES6 loop : 就我而言,node.js很老,并且不支持新的ES6循环

for(file of eclipseFiles) {

I followed these steps in order to upgrade node.js: 我按照以下步骤来升级node.js:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Upgrade NodeJS to the latest version on Mac os 在Mac OS上将NodeJS升级到最新版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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