Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: Unexpected token [ - ionic

I'm trying to start off my first ionic app; getting 'SyntaxError: Unexpected token [' on every ionic commands. Literally all ionic commands returning the same output.

$ ionic start test --v2

/Users/user/.nvm/versions/node/v4.1.1/lib/node_modules/ionic/dist/index.js:24
        const [xcode, iosDeploy, iosSim,] = yield Promise.all([
              ^

SyntaxError: Unexpected token [
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/user/.nvm/versions/node/v4.1.1/lib/node_modules/ionic/bin/ionic:8:11)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)

NPM: 4.5.0

OS: OSX Sierra

like image 832
Abdul Sadik Yalcin Avatar asked May 13 '17 00:05

Abdul Sadik Yalcin


1 Answers

The solution is not to downgrade as suggested by the previously accepted answer, but to upgrade Node as suggested in this answer.

Ionic needs to run on Node > 6.

So I was solving it upgrading Node on my Mac using Brew like:

brew upgrade node
brew link --overwrite node

First one was upgrading Node. The second one was needed to overwrite other Node binaries I had.

Using Node 7 I was able to execute the ionic command.

like image 73
Christian Avatar answered Nov 15 '22 06:11

Christian