I have two files :
- app.js
- module.js
app.js will have expression,
import 'foo' from './module'
//use foo..
and module.js will have,
export default {expression}
But it is not working. I'm currently using Node 7.0.0 I tries using Webpack with babel-loader and es2015 preset but not working.
-
import syntax is not present in node.js yet, check this thread.bpinhosilva– bpinhosilva2016年11月13日 16:47:35 +00:00Commented Nov 13, 2016 at 16:47
1 Answer 1
Your import does not need the quotes, or braces if importing a default export:
import foo from './module';
Also your export should look something like:
export default expression;
and if the exported item is called expression you'd import it as:
import expression from './module';
(you need the braces when importing non-default exports).
Very good in-depth explanation here:
answered Nov 13, 2016 at 13:50
Mark Williams
2,3081 gold badge14 silver badges15 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Mark Williams
bpinhosilva is correct; import won't work at all unless you are transpiling
lang-js