Javascript 运行节点4.4.7时收到严格模式警告
我相信节点v4.4.7支持ES6。但是,节点拒绝编译我的程序:Javascript 运行节点4.4.7时收到严格模式警告,javascript,node.js,ecmascript-6,let,strict,Javascript,Node.js,Ecmascript 6,Let,Strict,我相信节点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 suppo
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
我想避免“严格使用”。还有其他选项吗?运行
节点--使用严格索引.js
强制使用严格模式运行节点--使用严格索引.js
强制使用严格模式运行可能是这个答案?我不想在每个文件上都加上“use strict”。还有其他选择吗?我认为在v4.x中,节点默认是在严格模式下运行的。维尔德。尝试运行节点--使用_strictindex.js
为什么不切换到较新的节点版本?当前的稳定版本对ES6的支持要好得多。@GrégoryNEUT将您的回答作为一个答案,以便我可以将其标记为可能是这个答案吗?我不想在每个文件上都加上“use strict”。还有其他选择吗?我认为在v4.x中,节点默认是在严格模式下运行的。维尔德。尝试运行节点--使用_strictindex.js
为什么不切换到较新的节点版本?当前的稳定版本对ES6的支持要好得多。@GrégoryNEUT将您的回答作为一个答案,这样我就可以这样标记了