Skip to content

Failed to load plugin in configuration #2481

Open
@jdbruijn

Description

@jdbruijn

Expected Behavior

I'd expect it to load the plugin as it did previously. I'm not sure what changed between now and 'previously', whether that is node/npm version or something else.

Current Behavior

Loading a plugin of a configuration fails.

Edit: It the plugin is found as expected when I install @commitlint/cli@11.0.0 instead of 12.0.0 or 12.0.1, so it seems to me this bug was introduced in 12.0.0. The two suspects in that release, based on the changelog would IMO be #2070 and #982, where the former is IMHO most likely.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

What works, but is very undesired, is installing the plugin manually as user of my configuration.

Steps to Reproduce (for bugs)

  1. Create an empty workspace mkdir test && cd test
  2. Install @commitlint/cli and @vidavidorra/commitlint-config
    npm i -D @commitlint/cli@12.0.1 @vidavidorra/commitlint-config@2.1.13
  3. Create a configuration
    echo "module.exports = { extends: ['@vidavidorra/commitlint-config'] };" > commitlint.config.js
  4. Test a commit message
    $ echo 'test (fail)' | npx --no-install commitlint
    Failed to load plugin commitlint-plugin-function-rules.
    /home/jdebruijn/projects/node_modules/@commitlint/cli/lib/cli.js:106
            throw err;
            ^
    
    MissingPluginError: Failed to load plugin function-rules: Cannot find module 'commitlint-plugin-function-rules'
    Require stack:
    - /home/jdebruijn/projects/node_modules/@commitlint/load/lib/utils/load-plugin.js
    - /home/jdebruijn/projects/node_modules/@commitlint/load/lib/load.js
    - /home/jdebruijn/projects/node_modules/@commitlint/cli/lib/cli.js
    - /home/jdebruijn/projects/node_modules/@commitlint/cli/cli.js
        at Object.loadPlugin [as default] (/home/jdebruijn/projects/node_modules/@commitlint/load/lib/utils/load-plugin.js:32:23)
        at /home/jdebruijn/projects/node_modules/@commitlint/load/lib/load.js:66:38
        at Array.forEach (<anonymous>)
        at Object.load [as default] (/home/jdebruijn/projects/node_modules/@commitlint/load/lib/load.js:64:24)
        at processTicksAndRejections (node:internal/process/task_queues:94:5)
        at async main (/home/jdebruijn/projects/node_modules/@commitlint/cli/lib/cli.js:140:20) {
      messageTemplate: 'plugin-missing',
      messageData: {
        pluginName: 'commitlint-plugin-function-rules',
        commitlintPath: '/home/jdebruijn/projects/node_modules/@commitlint/load'
      }
    }
commitlint.config.js
module.exports = {
  extends: ['@vidavidorra/commitlint-config'],
};

Context

I have a shared configuration, @vidavidorra/commitlint-config, which uses a plugin, commitlint-plugin-function-rules as plugin. In my configuration I have the plugin as npm dependency. In my configuration I use this plugin to create certain rules. Users of my configuration get an error about the plugin of my configuration not being found, where users only install @vidavidorra/commitlint-config and not its dependencies, which they shouldn't need to care about.

Your Environment

Executable Version
commitlint --version 12.0.1
git --version 2.30.1
node --version 15.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions