【开发问题记录】执行 git cz 报require() of ES Module…… 错误

文章目录

1、问题

在对 commitizen 进行完,一系列的初始化以后 , 对代码进行 提交 到暂存区,然后要提交到 本地仓库 的报错

然后因为安装了 commitizen 所以是想用 git cz 进行提交的, 执行命令的时候确报错了

shell 复制代码
require() of ES Module F:\个人项目\dida_client_pc\.cz-config.js from F:\个人项目\dida_client_pc\node_modules\.pnpm\find-config@1.0.0\node_modules\find-config\src\find-config.js not supported..cz-config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.Instead either rename .cz-config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in F:\个人项目\dida_client_pc\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

2、解决

其实看这个报错的大概意思,也能猜到,是 module 和 commonjs 相互转化的问题

这个项目是 vue3 项目,vue3默认都是 module 的, 所以还得从这个 插件 下手,进行解决 ,然后在 GitHub上找到了这个

解决方案

1、把 .cz-config.js 重命名 为 .cz-config.cjs

2、修改 package.json 文件 ,增加这个 cz-customizable 的配置

js 复制代码
  "config": {
    "cz-customizable": {
      "config": ".cz-config.cjs"
    }
  }

3、参考链接

相关推荐
菌菌的快乐生活4 分钟前
在 WPS 中设置 “第一章”“第二章” 这类一级编号标题自动跳转至新页面
前端·javascript·wps
hh随便起个名30 分钟前
useRef和useState对比
前端·javascript·react
Hello_Embed36 分钟前
LVGL 入门(十五):接口优化
前端·笔记·stm32·单片机·嵌入式
十七号程序猿1 小时前
Java图书管理系统 | 无需配置任何环境,双击一键启动,开箱即用
java·spring boot·vue·毕业设计·毕设·源代码管理
huabiangaozhi1 小时前
spring-boot-starter和spring-boot-starter-web的关联
前端
umeelove351 小时前
Spring boot整合quartz方法
java·前端·spring boot
吴声子夜歌1 小时前
JavaScript——对象
开发语言·javascript·ecmascript
小码哥_常1 小时前
Android 开发探秘:View.post()为何能获取View宽高
前端
爱学习的程序媛1 小时前
【Web前端】WebAssembly详解
前端·web·wasm
不会写DN1 小时前
Js常用的字符串处理
开发语言·前端·javascript