[英]NodeJs error of 'The ESM module loader is experimental' after using --experimental-modules
I wrote this on package.json我在 package.json 上写了这个
"start:server": "nodemon --experimental-modules --es-module-specifier-resolution=node src/index server.js"
OR或者
"start:server": "nodemon --experimental-modules server.js"
server.js服务器.js
import { LoginPageModule } from './src/app/login/login.module';
Error:错误:
(node:16628) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/run_main.js:54
internalBinding('errors').triggerUncaughtException(
You need to add the .js
to the import, unless you also add --experimental-specifier-resolution=node
.您需要将
.js
添加到导入中,除非您还添加--experimental-specifier-resolution=node
。
This changes node's default explicit
setting which requires file extensions to be set, which then allows files without an extension to be seen as .js
files.这会更改节点的默认
explicit
设置,该设置需要设置文件扩展名,然后允许将没有扩展名的文件视为.js
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.