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
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.jsonstructure 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
resolvePkgstep is where it fails and it seems now there areexportsin the root package.json file of the lerna dependency.Current Behavior
Error when trying to do a commit with
@commitlint/config-lerna-scopesenabledExpected 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
lerna.json
{ "$schema": "node_modules/lerna/schemas/lerna-schema.json", "useWorkspaces": true, "version": "0.0.0", "npmClient": "yarn", "packages": ["packages/*"] }Environment