启用


¥Enabling

Node.js 有两个模块系统:CommonJS 模块和 ECMAScript 模块。

¥Node.js has two module systems: CommonJS modules and ECMAScript modules.

作者可以通过 .mjs 文件扩展名、package.json "type" 字段、或 --input-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, or the --input-type flag. Outside of those cases, Node.js will use the CommonJS module loader. See Determining module system for more details.