Cordova无法添加平台

时间:2016-11-06 05:27:28

标签: cordova cordova-cli

我正在使用cordova CLI。我正在尝试添加平台但是不起作用。 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

enter image description here

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。

就我而言,node.js已经很老了,它不支持新的ES6 loop

for(file of eclipseFiles) {

我按照以下步骤升级node.js:

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

Upgrade NodeJS to the latest version on Mac os