【发布时间】:2018-03-10 21:57:18
【问题描述】:
我在渲染 nodejs 项目时发现以下错误
{"level":"error","message":"uncaughtException SyntaxError: Use of const 处于严格模式。\n 在 Module._compile (module.js:439:25)\n 在 Object.Module._extensions..js (module.js:474:10)\n 在 Module.load (module.js:356:32)\n 在 Function.Module._load (module.js:312:12)\n 在 Module.require (module.js:364:17)\n at require (module.js:380:17)\n at 目的。 (/var/www/myproject/dist/node_modules/sparkpost/node_modules/request/node_modules/hawk/lib/index.js:5:33)\n 在 Module._compile (module.js:456:26)\n 在 Object.Module._extensions..js (module.js:474:10)\n 在 Module.load (module.js:356:32)\n 在 Function.Module._load (module.js:312:12)\n 在 Module.require (module.js:364:17)\n at require (module.js:380:17)\n at 目的。 (/var/www/myproject/dist/node_modules/sparkpost/node_modules/request/request.js:9:12)\n 在 Module._compile (module.js:456:26)\n 在 Object.Module._extensions..js (module.js:474:10)","timestamp":"2017-09-25T02:45:43.418Z"}
这就是为什么我检查我的 package.json 文件中的 sparkpost 版本并找到 "sparkpost": "^1.3.7", 但是当我检查 npm info sparkpost version 时,它转到 2.1.2
有什么建议可以帮助我检查 sparkpost 的实际版本以及如何修复该错误消息,谢谢。
【问题讨论】:
-
看起来
sparkpost实际上并不支持非常旧的 Node.js 版本。至少升级到 Node 4.x 可能是您最好的解决方案。我也为此打开了a GitHub issue。 -
@EwanDennis 你能告诉我如何使用
Old Node.js needs --harmony to enable const. -
我怀疑继续使用 Node.js 0.10 会解决这个问题。我强烈建议您至少升级到 Node.js v4。当前版本始终链接在https://nodejs.org/en/。