conventional-changelog / commitlint

📓 Lint commit messages
https://commitlint.js.org
MIT License
17.36k stars 929 forks source link

fix: Bun cannot run commitlint globally #4285

Closed ParzivalVulpine closed 1 month ago

ParzivalVulpine commented 1 month ago

Steps to Reproduce

On a M1 MacBook Pro running macOS 15.3
1. Run `bun install -g @commitlint/{cli,config-conventional}`
2. Run `echo "module.exports = {extends: ['@commitlint/config-conventional']};" > ~/.commitlintrc.js`
3. Run `echo 'should fail' | commitlint --config ~/.commitlintrc.js`

Current Behavior

Image
file:///Users/parzv/.bun/install/global/node_modules/@commitlint/cli/lib/cli.js:132
        throw err;
        ^

Error: Cannot find module "@commitlint/config-conventional" from "/Users/parzv"
    at resolveId (file:///Users/parzv/.bun/install/global/node_modules/@commitlint/resolve-extends/lib/index.js:148:17)
    at resolveConfig (file:///Users/parzv/.bun/install/global/node_modules/@commitlint/resolve-extends/lib/index.js:132:20)
    at file:///Users/parzv/.bun/install/global/node_modules/@commitlint/resolve-extends/lib/index.js:93:26
    at Array.reduce (<anonymous>)
    at loadExtends (file:///Users/parzv/.bun/install/global/node_modules/@commitlint/resolve-extends/lib/index.js:92:22)
    at resolveExtends (file:///Users/parzv/.bun/install/global/node_modules/@commitlint/resolve-extends/lib/index.js:76:28)
    at load (file:///Users/parzv/.bun/install/global/node_modules/@commitlint/load/lib/load.js:47:28)
    at async main (file:///Users/parzv/.bun/install/global/node_modules/@commitlint/cli/lib/cli.js:200:20) {
  code: 'MODULE_NOT_FOUND'
}

Node.js v23.7.0

Expected Behavior

Should output the linters analysis on my message

Affected packages

Possible Solution

No response

Context

I was interested in using bun for JS development and tried to install the cli utility to run globally through bun.

commitlint --version

@commitlint/cli@19.7.1

git --version

git version 2.39.5 (Apple Git-154)

node --version

v23.7.0

ParzivalVulpine commented 1 month ago

I want to note, that I accidentally discovered that apparently if I install @commitlint/config-conventional through npm, it seems to work (with commitlint installed from bun)

Image

I assume this is not intended behavior and it would be best for commitlint and config-conventional to work from just installing them through bun like I detailed above in my issue.

escapedcat commented 1 month ago

This might be related to or duplicates #613 ?

rubin55 commented 1 month ago

This is not macos-specific (encountering this on Arch Linux). I'm running into the same issue with no obvious fix; I want to install commitlint globally; I've tried many invocations of commitlint, combined with all kinds of commitlintrc[ts/mjs/js/etc] but I CAN'T get it to work at all. Why is this so hard?