【问题标题】:SyntaxError: Unexpected token [ - ionicSyntaxError: Unexpected token [ - ionic
【发布时间】:2017-06-03 03:58:35
【问题描述】:

我正在尝试启动我的第一个 ionic 应用程序;在每个离子命令上得到“SyntaxError: Unexpected token [”。从字面上看,所有离子命令都返回相同的输出。

$ 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

操作系统:OSX Sierra

【问题讨论】:

  • 遇到同样的问题...

标签: ionic-framework npm


【解决方案1】:

解决方案不是按照之前接受的答案的建议降级,而是升级节点as suggested in this answer

Ionic 需要在 Node > 6 上运行。

所以我正在使用 Brew 在我的 Mac 上升级 Node 来解决它,例如:

brew upgrade node
brew link --overwrite node

第一个是升级节点。需要第二个来覆盖我拥有的其他 Node 二进制文件。

使用 Node 7,我能够执行 ionic 命令。

【讨论】:

  • 你说得对,我更新到 v6.10.3 并修复了我的错误,你的是更好的选择
猜你喜欢
  • 2016-11-28
  • 2017-10-11
  • 1970-01-01
  • 2012-05-17
  • 2019-02-10
  • 2019-11-10
  • 2014-07-08
  • 2013-11-15
  • 2020-09-26
相关资源
最近更新 更多