--input-type=type


这将 Node.js 配置为将 --evalSTDIN 输入解释为 CommonJS 或 ES 模块。有效值为 "commonjs""module"。除非使用 --experimental-default-type=module,否则默认值为 "commonjs"

¥This configures Node.js to interpret --eval or STDIN input as CommonJS or as an ES module. Valid values are "commonjs" or "module". The default is "commonjs" unless --experimental-default-type=module is used.

REPL 不支持此选项。将 --input-type=module--print 一起使用会引发错误,因为 --print 不支持 ES 模块语法。

¥The REPL does not support this option. Usage of --input-type=module with --print will throw an error, as --print does not support ES module syntax.