node.js – Nodejs应用程序SyntaxError:意外的保留字’class’

前端之家收集整理的这篇文章主要介绍了node.js – Nodejs应用程序SyntaxError:意外的保留字’class’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是新手节点刚开始使用 eclipse和nod eclipse插件的应用程序.当我使用节点core.js运行应用程序时它工作正常,但使用eclipse它显示我跟随错误.
  1. /home/sarojs/projects/Core/security.js:3
  2. class Security {
  3. ^^^^^
  4. SyntaxError: Unexpected reserved word
  5. at exports.runInThisContext (vm.js:73:16)
  6. at Module._compile (module.js:443:25)
  7. at Object.Module._extensions..js (module.js:478:10)
  8. at Module.load (module.js:355:32)
  9. at Function.Module._load (module.js:310:12)
  10. at Module.require (module.js:365:17)
  11. at require (module.js:384:17)
  12. at Object.<anonymous> (/home/sarojs/projects/node/liveprojects/ecurvInc/Core/core.js:12:16)
  13. at Module._compile (module.js:460:26)
  14. at Object.Module._extensions..js (module.js:478:10)

无法弄清楚这里有什么问题.我搜索解决方案,发现了一些资源Unexpected reserved word,但不明白如何融入我的日食

我的package.json看起来像

  1. {
  2. "dependencies": {
  3. "bluebird": "^3.4.0","body-parser": "~1.8.1","cookie-parser": "~1.3.3","cors": "^2.8.1","debug": "~2.0.0","express": "~4.9.0","express-handlebars": "^3.0.0","express-session": "^1.13.0","MysqL": "^2.11.1","passport": "^0.3.2","passport-local": "^1.0.0"
  4. }
  5. }

仅供参考:
我的节点版本是4.4.6

IDE使用nodeclipse插件eclipse Mars 1

任何帮助将受到高度赞赏.

解决方法

类声明是ES6功能. ES6在节点4.4.6中具有 are hardly supported.尝试 updating并再次运行npm install

另见https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class

猜你在找的Node.js相关文章