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();
真诚赞赏,手留余香
赞赏
Web Server
Nginx 的 location 设置
2022-07-02
MySQL
MySQL DATETIME 时间查询和转换
2022-07-11
ngtwewy
随机推荐
Nginx 通过日志统计访问数据
Debian11 安装笔记3:安装 MySQL 5.7
CSS 媒体特性 prefers-color-scheme
MySQL的外键总结
JavaScript console 的用法
Node.js MySQL2 如何编写事务
Linux 中 top 命令的 Load Average 含义
如何调整 iconfont 图标的位置和基线
WordPress 支持事务
Debian11 安装笔记4:安装常用软件

微信联系我

夜间模式切换
回到顶部