Open alexandrulesi opened 4 months ago
The same applies to a MacBook Pro with an M3 Pro on macOS Sonoma.
Error: Cannot find module 'lefthook-darwin-arm64/bin/lefthook'
Require stack:
- /Users/flntzr/workspace/exampleProject/node_modules/lefthook/get-exe.js
- /Users/flntzr/workspace/exampleProject/node_modules/lefthook/bin/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Function.resolve (node:internal/modules/helpers:190:19)
at getExePath (/Users/flntzr/workspace/exampleProject/node_modules/lefthook/get-exe.js:17:18)
at Object.<anonymous> (/Users/flntzr/workspace/exampleProject/node_modules/lefthook/bin/index.js:9:5)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/flntzr/workspace/exampleProject/node_modules/lefthook/get-exe.js',
'/Users/flntzr/workspace/exampleProject/node_modules/lefthook/bin/index.js'
]
}
Hey! Do you skip installation of optionalDependencies
? Could you share the way you install lefthook? It should usually go to devDependencies
.
Since 1.6.8 there was nothing special added to package management.
I am not entirely sure what happened here but after another npm install
it seems to be working with 1.6.10 as well. I did not skip any optionalDependencies
and lefthook is part of the devDependencies
.
The project in question is a monorepo using npm workspaces in combination with lerna and I suspect this has introduced some flakiness since we've seen a similar issue before. If it's relevant, it previously occurred with lightningcss-linux-arm64-gnu
.
@alexandrulesi Do you have a similar project setup, i.e. lerna and/or npm workspaces could be to blame?
I believe the error we're seeing here is related to this bug in the npm CLI and can be closed here.
I've had a similar issue on Windows 10 (but with a slightly different, windows-related error message, obviously).
Reverting to previous version fixed the issue.
Perhaps its related to #722, about virus scanners detecting the latest lefthook as a virus. Windows Security did warn me about an issue today, which went away after reverting to the previous version of lefthook.
I don't remember upgrading lefthook TODAY, when I started seeing problems, which is why I think it might be related to #722.
Partial package.json below, post reversion. (I'm sure anyone reading this would already understand how to revert to an early version, but just in case...)
"devDependencies": {
"lefthook": "1.6.11",
}
Hey! Does the issue still persist with the lefthook v1.6.16?
Just got a similar error on a macos x64 and version ^1.6.18
Cannot find module 'lefthook-darwin-x64/bin/lefthook'
So I'd say yes.
What package manager do you use?
:wrench: Summary
In an npm environment after updating lefthook to
1.6.10
package version I am no longer able to make commits on my Fedora Linux 39 Workstation machine. I don't have the issue on1.6.8
.I'm also not seeing any of these packages mentioned in the package lock in the node_modules folder:
Lefthook version
package.json dependency version
1.6.10
. Trying to callnpx lefthook version -f
throws the same error mentioned below.Steps to reproduce
1.6.10
npm i
Expected results
Successful commit
Actual results
Error: Cannot find module 'lefthook-linux-x64/bin/lefthook'
Logs / Screenshots