启用
Node.js 默认将 JavaScript 代码视为 CommonJS 模块。
作者可以通过 .mjs
文件扩展名、package.json
"type"
字段、或 --input-type
标志告诉 Node.js 将 JavaScript 代码视为 ECMAScript 模块。
Node.js treats JavaScript code as CommonJS modules by default.
Authors can tell Node.js to treat JavaScript code as ECMAScript modules
via the .mjs
file extension, the package.json
"type"
field, or the
--input-type
flag. See
Modules: Packages for more
details.