【问题标题】:Receiving strict mode warning while running node 4.4.7运行节点 4.4.7 时收到严格模式警告
【发布时间】:2017-02-01 16:54:06
【问题描述】:

我相信 node v4.4.7 支持 ES6。但是节点拒绝编译我的程序:

user1-$ node -v
v4.4.7

user1-$ node index.js
event-service.js:85
      let sql = 'SELECT * FROM group_events where id = ?';
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

我想避免“使用严格”。还有其他选择吗?

【问题讨论】:

  • 我不想在每个文件的顶部放置“使用严格”。还有其他选择吗?
  • 我认为 node 在 v4.x 中默认以严格模式运行。奇怪。尝试运行node --use_strict index.js
  • 为什么不切换到更新的节点版本?当前的稳定版本有更好的 ES6 支持。
  • @GrégoryNEUT 将您的回复作为答案,以便我可以标记它

标签: javascript node.js ecmascript-6 let strict


【解决方案1】:

运行node --use_strict index.js 强制使用严格模式

【讨论】:

    猜你喜欢
    • 2021-03-09
    • 2015-01-30
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    • 2021-04-29
    • 2020-06-13
    • 1970-01-01
    • 2021-09-25
    相关资源
    最近更新 更多