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();
声明:本站所有文章和图片,如无特殊说明,均为原创发布,转载请注明出处。
随机推荐
WordPress 一键从HTTP转换到HTTPS
WordPress 分类添加自定义字段
WordPress 后台添加菜单
CSRF 双重 Cookie 验证
JavaScript URL 对象
WordPress 语言文件
JavaScript 字符串详细介绍
WordPress 文章页作者信息 get_the_author() 和 get_the_author_meta()