I\'m using WebStorm latest version to work with Node.js (express.js) frame work. I have set my Babel so that I can use ES6 syntax, for example:
import expres
same as @lena but I'm using "@babel/register", I added --require @babel/register
To make things clear: you issue has absolutely nothing to do with WebStorm, error comes from Node.js interpreter that runs your code. Node.js still doesn't support ES6 modules natively (actually, no JavaScript runtime currently supports them - ECMAScript does not define a "Loader" specification which determines how Modules are inserted into the runtime. The Loader spec is being defined by WHATWG, but is not yet finalized). So, to get ES6 imports/exports accepted, you need using transpilers. Current industry standard is Babel
To make things work, try the following:
npm install --save-dev babel-cli babel-preset-env
create a .babelrc
file in project root dir:
{ "presets": ["env"] }
in your Node.js Run configuration, pass -r babel-register
to Node: