Skip to content

fix: @commitlint/config-nx-scopes not working for nx since version v19 #3978

@timonmasberg

Description

@timonmasberg

Steps to Reproduce

1. First step
https://github.com/timonmasberg/commitlint-nx-bug
2. Second step
`git commit -m "chore: oh no"`

Current Behavior

Throws an error, probably due to the ESM changes introduced in v19.

file:///.../commitlint-nx-19/node_modules/@commitlint/cli/lib/cli.js:127
        throw err;
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../commitlint-nx-19/node_modules/nx/src/generators/utils/project-configuration' imported from.../commitlint-nx-19-bug/commitlint-nx-19/node_modules/@commitlint/config-nx-scopes/index.js
Did you mean to import .../commitlint-nx-19/node_modules/nx/src/generators/utils/project-configuration.js?
    at finalizeResolution (node:internal/modules/esm/resolve:255:11)
    at moduleResolve (node:internal/modules/esm/resolve:908:10)
    at defaultResolve (node:internal/modules/esm/resolve:1121:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///.../commitlint-nx-19/node_modules/nx/src/generators/utils/project-configuration'
}

Expected Behavior

It should be able to get the configuration and lint the message.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Adding file extensions to nx imports (https://nodejs.org/api/esm.html#esm_mandatory_file_extensions)

Context

Migrating to NX 18, bumped commitlint packages manually, error encountered. Probably not related to nx, rather than how you use the nx modules.

commitlint --version

@commitlint/[email protected]

git --version

2.39.2

node --version

20.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions