Skip to content

Can not use @commitlint/cz-commitlint as commitizen's adapter #3949

Closed
@wangys4dev

Description

@wangys4dev

Steps to Reproduce

1. setup scripts and install packages:

{
  "scripts": {
    "cz": "cz",
  },
  "devDependencies": {
    "@commitlint/cli": "^19.0.3",
    "@commitlint/config-conventional": "^19.0.3",
    "@commitlint/cz-commitlint": "^19.0.3",
    "commitizen": "^4.3.0"
  }
}

2. configs:
```jsonc
// .commitlintrc.json
{
  "extends": ["@commitlint/config-conventional"]
}
// .cz.json
{
  "path": "@commitlint/cz-commitlint"
}
  1. run pnpm cz

Current Behavior

got error

require() of ES Module C:\Users\admin\workspace\admin-template-vue\node_modules\.pnpm\@commitlint+cz-commitlint@19.0.3_@types+node@20.11.24_commitizen@4.3.0_inquirer@9.2.15_typescript@5.3.3\node_modules\@commitlint\cz-commitlint\lib\index.js from C:\Users\admin\workspace\admin-template-vue\node_modules\.pnpm\commitizen@4.3.0_@types+node@20.11.24_typescript@5.3.3\node_modules\commitizen\dist\commitizen\adapter.js not supported.
Instead change the require of index.js in C:\Users\admin\workspace\admin-template-vue\node_modules\.pnpm\commitizen@4.3.0_@types+node@20.11.24_typescript@5.3.3\node_modules\commitizen\dist\commitizen\adapter.js to a dynamic import() which is available in all CommonJS modules.
 ELIFECYCLE  Command failed with exit code 1.

Expected Behavior

Run commitizen normally

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

#3850

Context

No response

commitlint --version

@commitlint/cli@19.0.3

git --version

git version 2.44.0.windows.1

node --version

v20.11.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions