unexpected reserved word import in node.js

后端 未结 3 571
抹茶落季
抹茶落季 2020-12-08 06:15

I\'m trying to run node.js backend server. I\'ve received error unexpected reserved word on import in Node.js file.

The lines in file core.module.

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 06:49

    The import keyword is part of the modules feature in ECMAScript 2015, along with export and a few other specifications.

    It is currently not implemented natively in NodeJS, even on the lastest version (v0.12.7), nor is it supported in the ES2015 "friendlier" fork iojs.

    You will need to use a transpiler to get that to work.

    [edit] it's still unsupported in the latest version (v5.8) despite the existence of an --harmony_modules flag, which does nothing. Your best run is to use babel, as explained here and here

提交回复
热议问题