require
CommonJS 模块 require
总是将它引用的文件视为 CommonJS。
¥The CommonJS module require
always treats the files it references as CommonJS.
不支持使用 require
加载 ES 模块,因为 ES 模块具有异步执行。而是,使用 import()
从 CommonJS 模块加载 ES 模块。
¥Using require
to load an ES module is not supported because ES modules have
asynchronous execution. Instead, use import()
to load an ES module
from a CommonJS module.