conventional-changelog / conventional-changelog/commitlint
Config not found when used with `rush` and `pnpm v7`
- Dominant language
- TypeScript
- Stars
- 18.7k
- Forks
- 970
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 49
Description
## Expected Behavior
All good
## Current Behavior
Error: Cannot find module "@commitlint/config-conventional"
## Affected packages
- [x] cli
- [ ] core
- [ ] prompt
- [ ] config-angular
## Steps to Reproduce (for bugs)
Repro here: https://github.com/Faithfinder/rush-pnpm7-commilint-repro
- Checkout `main`
- `rush update` to install git hooks
- Try to make a commit (empty is fine) with random letters, get error:
```
⧗ input: asdfasdf
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
```
- Try to make a commit conforming to standard, ie `test: commit`, succeed
- These steps are just to check that commitlint is set up correctly and working, all behaviour intended.
- Checkout [`pnpmv7`](https://github.com/Faithfinder/rush-pnpm7-commilint-repro/tree/pnpmv7) branch (or update pnpm to v7 in `rush.json`)
- Try to make the same conforming commit, get error:
```
dependencies:
+ @commitlint/cli 17.0.2
+ @commitlint/config-conventional 17.0.2
Progress: resolved 189, reused 189, downloaded 0, added 189, done
Auto install completed successfully
Error: Cannot find module "@commitlint/config-conventional" from "/home/misamoto/Source/OpenSource/rush-pnpm7-commilint-repro"
```
.commitlintrc.json
```json
{
"extends": ["@commitlint/config-conventional"]
}
```
## Context
I've initially opened the bug report in [`rushstack`](https://github.com/microsoft/rushstack/issues/3526) repo, however it was closed with a statement that the error is on commitlint's side, so now I'm hoping for you guys to release a fix. Here's the full response from `rushstack`:
> This isn't an issue with Rush or PNPM, it's an issue with commitlint. Changing [this line](https://github.com/conventional-changelog/commitlint/blob/82b410576bf83f77f14ff4443a0aff5c64817889/%40commitlint/cli/src/cli.ts#L203) to `cwd: __dirname` and [this line](https://github.com/conventional-changelog/commitlint/blob/82b410576bf83f77f14ff4443a0aff5c64817889/%40commitlint/load/src/load.ts#L58) to `cwd: cwd` fixes the issue. `commitlint` uses an incorrect assumption about the way it was installed when performing module resolution that was exposed by changes to the installation topology in PNPM 7.
>
> I'd recommend you raise an issue with commitlint. They should be able to fix this issue by either using a more conventional module resolution tool (like node's built-in `require`) or correctly passing module context between calls to their custom module resolver.
## Workaround:
Target the config directly:
```json
{
"extends": ["./common/autoinstallers/commitlint/node_modules/@commitlint/config-conventional/index.js"]
}
```
Contributor guide
Assessment
This issue has not been assessed yet.