--experimental-modules
我尝试在带有标志的 Node.js v8.7.0 中使用此语法导入 ESM 模块:
import { check, validationResult } from 'express-validator/check';
import { matchedData, sanitize } from 'express-validator/filter';
但是我收到以下错误:
(node:29028) ExperimentalWarning: The ESM module loader is experimental.
SyntaxError: The requested module does not provide an export named 'check'
at checkComplete (internal/loader/ModuleJob.js:86:27)
at moduleJob.linked.then (internal/loader/ModuleJob.js:69:11)
at <anonymous>
--experimental-modules
使用标志打开 ESM 模块的正确用法是什么?
我也用@std/esm
包测试过。它只适用于我转cjs: true
。