"进出口QUOT;节点ES6 [英] "Import" ES6 for Node
问题描述
我想使用从ES6导入,而不是要求从node中的common.js。
由于某些原因,我认为导入将在默认情况下在Node中工作。但是看起来好像没有。有没有一些npm软件包我需要安装才能工作?
I want to use import from ES6 rather than require from common.js in Node. For some reason I thought import would work by default in Node. But looks like it does not. Is there some npm package i need to install for that to work?
推荐答案
Node.js当前不支持ES6模块。您需要使用单独的包来实现此行为。
Node.js does not currently support ES6 modules natively. You'd need to use a separate package to implement this behavior.
事实上的标准将是 es6-module-loader ,它在浏览器和Node环境中工作。
The de-facto standard would be es6-module-loader, which works in the browser as well as in a Node environment.
Babel.js
使用 System.js
,它使用 es6-module-loader
是核心。如果它不适合您,这可能是您的实施问题。
Babel.js
uses System.js
, which uses es6-module-loader
at it's core. If it didn't work for you, it's likely an issue with your implementation.
这篇关于"进出口QUOT;节点ES6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!