typicode / husky

Git hooks made easy 🐶 woof!
https://typicode.github.io/husky
MIT License
31.68k stars 996 forks source link

ERR_MODULE_NOT_FOUND on Husky 9.0.10 #1390

Closed Virakal closed 3 months ago

Virakal commented 3 months ago

After upgrading from 9.0.6 to 9.0.10 I'm getting the following error when running yarn husky:

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/xxx/.yarn/berry/cache/husky-npm-9.0.10-93b6062488-10c0.zip/node_modules/husky/bin.mjs' imported from /home/xxx/Repos/xxx/xxx/
Did you mean to import /home/xxx/.yarn/berry/cache/husky-npm-9.0.10-93b6062488-10c0.zip/node_modules/husky/bin.mjs?
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)
    at moduleResolve (node:internal/modules/esm/resolve:980:10)
    at defaultResolve (node:internal/modules/esm/resolve:1193:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at ModuleLoader.import (node:internal/modules/esm/loader:335:34)
    at node:internal/modules/run_main:92:28
    at loadESM (node:internal/process/esm_loader:34:13) {
  url: 'file:///home/xxx/.yarn/berry/cache/husky-npm-9.0.10-93b6062488-10c0.zip/node_modules/husky/bin.mjs',
  code: 'ERR_MODULE_NOT_FOUND'
}

I'm using Yarn 4.1.0 on WSL 2, using Zsh. Reverting to 9.0.6 means I can run the setup again. I've tried clearing the Yarn cache but nothing improves. I've tried it on Node 18 and 20.

Virakal commented 3 months ago

Just tested - 9.0.8 works for me but 9.0.9 does not.

typicode commented 3 months ago

I'm not sure why it's not finding it. Are you trying to import husky/bin.mjs?

Virakal commented 3 months ago

I'm just running yarn husky from Zsh. I've tried it with Yarn 1.x and Yarn 4.x with the node_modules linker enabled and it works fine so perhaps this is a Yarn bug rather than something on Husky's side?

typicode commented 3 months ago

It seems so. Thanks for the update :)