babel-preset-es2015
is installed, and is OK with es6 feature just like below let a = 2;
.
But can not work with es6 modules feature import
Got it from the official doc:http://babeljs.io/docs/usage/cli/
ES6-style module-loading may not function as expected
Due to technical limitations ES6-style module-loading is not fully supported in a babel-node REPL.
The error message is exactly what it says. You cannot use ES6 module syntax in the REPL, it is unsupported. You can create a small adapter that imports as ES6 and exports as CommonJS:
# es6-to-common.js
import MyThing from './somewhere';
module.exports = MyThing;
Now inside your usual babel-node
prompt:
> MyThing = require('./es6-to-common')