Kim
Kim

Reputation: 55

Cordova cant add platform

I'm using cordova CLI. I'm trying to add platform but is doesn't work. Nodejs, npm, android-sdk-linux are all installed.

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

Upvotes: 0

Views: 900

Answers (1)

Alberto
Alberto

Reputation: 853

I had the same problem.

In my case, node.js was quite old, and it did not support the new ES6 loop:

for(file of eclipseFiles) {

I followed these steps in order to upgrade node.js:

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

Upgrade NodeJS to the latest version on Mac os

Upvotes: 2

Related Questions