question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module "@commitlint/config-conventional" when running commintlint globally

See original GitHub issue

Expected Behavior

I installed commitlint and commitlint/config-conventional globally, thus running echo 'hello world' | commitlint under any directory should works.

Current Behavior

The command raises an exception.

/usr/local/lib/node_modules/@commitlint/cli/lib/cli.js:67
                throw err;
                ^

Error: Cannot find module "@commitlint/config-conventional" from "/home/fabrizio"
    at resolveId (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js:134:12)
    at resolveConfig (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js:111:18)
    at /usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js:63:18
    at Array.reduce (<anonymous>)
    at loadExtends (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js:61:32)
    at resolveExtends (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js:44:17)
    at Object.$If_1 (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/load.js:90:46)
    at Object.<anonymous> (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/load.js:159:18)
    at <anonymous>

Affected packages

  • cli
  • config-conventional

Steps to Reproduce (for bugs)

  1. npm install -g @commitlint/cli @commitlint/config-conventional
  2. echo "module.exports = {extends: ['@commitlint/config-conventional']};" > ~/.commitlintrc.js
  3. echo 'should fail' | commitlint
commitlint.config.js ```js module.exports = {extends: ['@commitlint/config-conventional']}; ```

Your Environment

Executable Version
commitlint --version 7.5.2
git --version 2.17.1
node --version 8.10.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:26
  • Comments:35 (8 by maintainers)

github_iconTop GitHub Comments

12reactions
escapedcatcommented, Apr 5, 2019

I think commitlint is usually being used on a per project basis. So each project has it’s own config. If you want to use it globally like you tried you could use the --config option and try this:

echo 'should fail' | commitlint --config ~/.commitlintrc.js
10reactions
politiciancommented, Jun 21, 2022

Workaround for those in the same case as me, manually include the rules from your chosen config in your commitlint.config.js config file.

Here are the rules for @commitlint/config-conventional in YAML:

.commitlintrc.yaml

---
# The rules below have been manually copied from @commitlint/config-conventional
# and match the v1.0.0 specification:
# https://www.conventionalcommits.org/en/v1.0.0/#specification
#
# You can remove them and uncomment the config below when the following issue is
# fixed: https://github.com/conventional-changelog/commitlint/issues/613
#
# extends:
#   - '@commitlint/config-conventional'
rules:
  body-leading-blank: [1, always]
  body-max-line-length: [2, always, 100]
  footer-leading-blank: [1, always]
  footer-max-line-length: [2, always, 100]
  header-max-length: [2, always, 100]
  subject-case:
    - 2
    - never
    - [sentence-case, start-case, pascal-case, upper-case]
  subject-empty: [2, never]
  subject-full-stop: [2, never, "."]
  type-case: [2, always, lower-case]
  type-empty: [2, never]
  type-enum:
    - 2
    - always
    - [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]
Read more comments on GitHub >

github_iconTop Results From Across the Web

@commitlint/config-conventional - npm
Start using @commitlint/config-conventional in your project by running `npm i @commitlint/config-conventional`. There are 927 other projects ...
Read more >
@commitlint/config-conventional | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
commitlint - Lint commit messages
commitlint helps your team adhere to a commit convention. By supporting npm-installed configurations it makes sharing of commit conventions easy.
Read more >
reactjs - Jest - Referencing local files gives package link error
When I try and run jest, I get the following error that makes my test file fail: The package 'sdk-test-project' doesn't seem to...
Read more >
Rush and Commitlint - DEV Community ‍ ‍
First, configure commitlint to use conventional config. ... Next time you run git commit , Git will find your script and invoke it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found