启用
¥Enabling
Node.js 有两个模块系统:CommonJS 模块和 ECMAScript 模块。
¥Node.js has two module systems: CommonJS modules and ECMAScript modules.
作者可以通过 .mjs
文件扩展名、package.json
"type"
字段、--input-type
标志或 --experimental-default-type
标志告诉 Node.js 使用 ECMAScript 模块加载器。在这些情况之外,Node.js 将使用 CommonJS 模块加载器。有关详细信息,请参阅 确定模块系统。
¥Authors can tell Node.js to use the ECMAScript modules loader via the .mjs
file extension, the package.json
"type"
field, the --input-type
flag, or the --experimental-default-type
flag. Outside of those cases,
Node.js will use the CommonJS module loader. See Determining module system
for more details.