【开发问题记录】执行 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、参考链接

相关推荐
huwuhang11 分钟前
跨平台电子书阅读器 | Readest最新版 安卓版+PC版全平台
android·前端·javascript
C澒12 分钟前
AI 生码:RAG 检索优化实现可评估、可回溯工程化
前端·ai编程
Shirley~~12 分钟前
力扣hot100:每日温度
开发语言·javascript·ecmascript
条tiao条13 分钟前
不止语法糖:TypeScript Set 与 Map 深度解析
前端·javascript·typescript
freewlt34 分钟前
React Server Components 深度解析:从原理到实战的完整指南
前端·javascript·react.js
zhensherlock1 小时前
Protocol Launcher 系列:1Writer iOS 上的 Markdown 文档管理
javascript·笔记·ios·typescript·node.js·iphone·ipad
ZC跨境爬虫1 小时前
Playwright进阶操作:鼠标拖拽与各类点击实战(含自定义拖拽实例)
前端·爬虫·python·ui
小江的记录本1 小时前
【RabbitMQ】RabbitMQ核心知识体系全解(5大核心模块:Exchange类型、消息确认机制、死信队列、延迟队列、镜像队列)
java·前端·分布式·后端·spring·rabbitmq·mvc
心静财富之门1 小时前
《前端零基础入门:HTML + CSS + JavaScript 全套速查表(详细版 + 实例)》
前端·javascript·python
星空1 小时前
前端--A_4--HTML表单
前端