Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commitlint hook fails with latest version #3579

@gvdp

Description

@gvdp

After upgrading to the latest lerna version in our monorepo, the commitlint hook fails.

Not sure this is something which should be fixed here, but it seems to occur because of some changes in the package.json structure which were introduced in v6.5.0. If not it's hopefully a good starting point for others experiencing the same issue.

I think it might have something to do with this issue, because the resolvePkg step is where it fails and it seems now there are exports in the root package.json file of the lerna dependency.

Current Behavior

Error when trying to do a commit with @commitlint/config-lerna-scopes enabled

Expected Behavior

Commitlint keeps working as before

Steps to Reproduce

Created an empty repo where the issue occurs:

https://github.com/gvdp/lerna-commitlint-repro

Failure Logs / Configuration

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at Object.join (node:path:1172:7)
    at getLernaVersion (/Users/gvdp/code/oss/lerna-commitlint/node_modules/@commitlint/config-lerna-scopes/index.js:57:22)
    at /Users/gvdp/code/oss/lerna-commitlint/node_modules/@commitlint/config-lerna-scopes/index.js:33:25
    at async execute (/Users/gvdp/code/oss/lerna-commitlint/node_modules/@commitlint/execute-rule/src/index.ts:20:16)
    at async Promise.all (index 0)
    at async load (/Users/gvdp/code/oss/lerna-commitlint/node_modules/@commitlint/load/src/load.ts:78:3)
    at async main (/Users/gvdp/code/oss/lerna-commitlint/node_modules/@commitlint/cli/src/cli.ts:214:17) {
  code: 'ERR_INVALID_ARG_TYPE'
}
lerna.json

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "useWorkspaces": true,
  "version": "0.0.0",
  "npmClient": "yarn",
  "packages": ["packages/*"]
}

Environment

✗ npx lerna info
lerna notice cli v6.5.1

 Environment info:

  System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.15.0 - ~/.volta/tools/image/node/16.15.0/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.5.5 - ~/.volta/tools/image/node/16.15.0/bin/npm
  Utilities:
    Git: 2.32.0 - /usr/bin/git
  npmPackages:
    lerna: 6.5.1 => 6.5.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions