Skip to content

Config not found when used with rush and pnpm v7 #3397

Open
@Faithfinder

Description

@Faithfinder

Expected Behavior

All good

Current Behavior

Error: Cannot find module "@commitlint/config-conventional"

Affected packages

  • 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 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 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 to cwd: __dirname and this line 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:

{
    "extends": ["./common/autoinstallers/commitlint/node_modules/@commitlint/config-conventional/index.js"]
}

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