conventional-changelog / commitlint

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

fix: Cannot find module '/Users/steven/Desktop/Github/constore-ui/node_modules/inquirer/lib/prompts/input.js' #4094

Open steven-fe opened 1 week ago

steven-fe commented 1 week ago

Steps to Reproduce

1. npm install --save-dev @commitlint/{cli,config-conventional,prompt-cli}
2. npx commit

Current Behavior

node:internal/modules/esm/resolve:255 throw new ERR_MODULE_NOT_FOUND( ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/steven/Desktop/Github/constore-ui/node_modules/inquirer/lib/prompts/input.js' imported from /Users/steven/Desktop/Github/constore-ui/node_modules/@commitlint/prompt/lib/inquirer/InputCustomPrompt.js

Expected Behavior

The "inquirer" module can be imported normally.

Affected packages

Possible Solution

The "inquirer" module should be used as is, for example:

bad: import InputPrompt from 'inquirer/lib/prompts/input.js';

Because the structure of the "inquirer" module may change!

Context

No response

commitlint --version

@commitlint/prompt@19.3.1

git --version

v2.42.0

node --version

v21.1.0

knocte commented 4 days ago
  1. npx commit

npx commit? shouldn't this be npx commitlint?

devmozao commented 4 days ago

same happening here since thursday. happening under node 22 and node 20, and also under bun 1.1.8

logs on node

$ commit
node:internal/modules/esm/resolve:304
  return new ERR_PACKAGE_PATH_NOT_EXPORTED(
         ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/prompts/input.js' is not defined by "exports" in /home/devmozao/makasi/app/node_modules/inquirer/package.json imported from /home/devmozao/makasi/app/node_modules/@commitlint/prompt/lib/inquirer/InputCustomPrompt.js
    at exportsNotFound (node:internal/modules/esm/resolve:304:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:651:9)
    at packageResolve (node:internal/modules/esm/resolve:837:14)
    at moduleResolve (node:internal/modules/esm/resolve:927:18)
    at defaultResolve (node:internal/modules/esm/resolve:1157:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:36) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v20.15.0
error: script "commit" exited with code 1

log on bun:

╰─❯ bun run --bun commit
$ commit
error: Cannot find module "inquirer/lib/prompts/input.js" from "/home/devmozao/makasi/app/node_modules/@commitlint/prompt/lib/inquirer/InputCustomPrompt.js"

Bun v1.1.18 (Linux x64)
error: script "commit" exited with code 1
knocte commented 4 days ago

Can you read my comment again? You're reporting a bug in the npm commitlint package repo, not commit repo.

devmozao commented 4 days ago

@knocte honest question: isn't this the docs of @commitlint? https://commitlint.js.org/guides/use-prompt.html

2024-07-06 03 51 56 commitlint js org a1f5951d27f1

cuz on the scripts of this docs, we're instructed to use "commit" as a shortcut of the prompt-cli.

unless there's another commitlint 19.3.0 that i'm unware of, cuz @commitlint on NPM redirects right to this space: @conventional-changelog/commitlint

and also, the @commitlint/cli again, reports to this repo on NPM. that's why we're here. it's not a "commit" package. it's a npm script-run command named "commit", that runs commitlint as a shortcut, as the docs says so.

again: unless I'm missing something really, really hard here, I don't know what else. cuz npx commitlint also isn't the answer to the trick that we used before - again - as we learned from the docs.

knocte commented 4 days ago

we're instructed to use "commit" as a shortcut of the prompt-cli.

Ok sorry I'm not familiar with the prompt tools, we should add prompt-cli to the title of this github issue.

devmozao commented 4 days ago

@knocte np! I'm also reaching out on Inquirer.js to see if this error is related to something that is used here on commitlint. Maybe something changed recently on their side and needs to be reflected here as well.

knocte commented 4 days ago

Yeah, I feel this must have been a breaking change of one of commitlint's dependencies because commitlint's latest release is not recent.

escapedcat commented 4 days ago

tbh I think prompt has issues since a longer time. If you want some sort of terminal ui maybe try cz-commitlint

devmozao commented 3 days ago

confirmed with the guys on Inquirer.js: it had recent changes. That's why we're getting this error.

"They should move to @inquirer/input or a custom prompt with @inquirer/core"

Will give it a try on cz-commitlint too.

devmozao commented 1 day ago

They made a rollback on @inquirer to keep this feature, since it has some other libs still using it, but the recommendation of theirs continue: to upgrade to @inquirer/core, because they're rewriting the lib itself, since its +10 years old.

Today I tested here and everything went back to normal. Will definitely keep an eye at @commitizen and see if I can improve, but I think this solves for now and this issue can be closed.

Thank you all for the attention given. o/

knocte commented 1 day ago

Sounds like they kicked the can down the road, hehe. Which means, it's just a workaround, not the ultimate fix. So I think this github issue should be left open until we can adopt @inquirer/core.

escapedcat commented 1 day ago

@devmozao thanks for the update! @knocte agreed, let's keep this open.