【发布时间】:2018-05-10 07:49:09
【问题描述】:
我使用的是 Node.js 10.0.0,我的 index.mjs 看起来像:
import path from "path";
console.log(__dirname);
在我的终端中,我运行
node --experimental-modules index.mjs
我收到以下错误:
(node:3750) ExperimentalWarning: The ESM module loader is experimental.
ReferenceError: __dirname is not defined
at file:///MyFolderPath/node-10/index.mjs:3:21
at ModuleJob.run (internal/modules/esm/module_job.js:106:14)
【问题讨论】:
标签: javascript node.js