ReferenceError: __dirname is not defined in ES module scope

ReferenceError: __dirname is not defined in ES module scope

This file is being treated as an ES module because it has a '.js' file extension and '/Users/ice/www/next/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.


解决办法:

import path from "path";
const __dirname = path.resolve();
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
真诚赞赏,手留余香
赞赏
随机推荐
Land APP 小程序
Git 放弃本地修改,强制和之前的某次提交同步
Wordpress 主样式表(style.css)
如何使主题支持 Woocommerce
WordPress 分页
Node.js 控制台进度条实现原理
macOS 生成 icns 图标
MySQL DATETIME 时间查询和转换