Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'lefthook-linux-x64/bin/lefthook' on git commit after updating npm dependency to 1.6.10 #708

Open
alexandrulesi opened this issue Apr 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@alexandrulesi
Copy link

alexandrulesi commented Apr 18, 2024

🔧 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 on 1.6.8.

I'm also not seeing any of these packages mentioned in the package lock in the node_modules folder:

  "packages": {
    ...
    "node_modules/lefthook": {
      "optionalDependencies": {
        "lefthook-darwin-arm64": "1.6.10",
        "lefthook-darwin-x64": "1.6.10",
        "lefthook-freebsd-arm64": "1.6.10",
        "lefthook-freebsd-x64": "1.6.10",
        "lefthook-linux-arm64": "1.6.10",
        "lefthook-linux-x64": "1.6.10",
        "lefthook-windows-arm64": "1.6.10",
        "lefthook-windows-x64": "1.6.10"
      }
    }
  }

Lefthook version

package.json dependency version 1.6.10. Trying to call npx lefthook version -f throws the same error mentioned below.

Steps to reproduce

  1. Upgrade dependency version to 1.6.10
  2. npm i
  3. Try to make any commit

Expected results

Successful commit

Actual results

Error: Cannot find module 'lefthook-linux-x64/bin/lefthook'

Logs / Screenshots

+ '[' '' = 0 ']'
+ call_lefthook run prepare-commit-msg .git/COMMIT_EDITMSG message
++ git rev-parse --show-toplevel
+ dir=/home/redacted
++ uname
++ tr '[:upper:]' '[:lower:]'
+ osArch=linux
++ uname -m
++ sed s/aarch64/arm64/
+ cpuArch=x86_64
+ test -n ''
+ lefthook -h
+ test -f /home/redacted/node_modules/lefthook/bin/index.js
+ /home/redacted/node_modules/lefthook/bin/index.js run prepare-commit-msg .git/COMMIT_EDITMSG message
node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module 'lefthook-linux-x64/bin/lefthook'
Require stack:
- /home/redacted/node_modules/lefthook/get-exe.js
- /home/redacted/node_modules/lefthook/bin/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Function.resolve (node:internal/modules/cjs/helpers:127:19)
    at getExePath (/home/redacted/node_modules/lefthook/get-exe.js:17:18)
    at Object.<anonymous> (/home/redacted/node_modules/lefthook/bin/index.js:9:5)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/redacted/node_modules/lefthook/get-exe.js',
    '/home/redacted/node_modules/lefthook/bin/index.js'
  ]
}

Node.js v18.17.1
@alexandrulesi alexandrulesi added the bug Something isn't working label Apr 18, 2024
@alexandrulesi alexandrulesi changed the title Error: Cannot find module 'lefthook-linux-x64/bin/lefthook' Error: Cannot find module 'lefthook-linux-x64/bin/lefthook' on git commit after updating npm dependency to 1.6.10 Apr 18, 2024
@flntzr
Copy link

flntzr commented May 13, 2024

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'
  ]
}

@mrexox
Copy link
Member

mrexox commented May 13, 2024

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.

@flntzr
Copy link

flntzr commented May 13, 2024

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?

@flntzr
Copy link

flntzr commented May 21, 2024

I believe the error we're seeing here is related to this bug in the npm CLI and can be closed here.

@JeffJacobson
Copy link

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",
}

JeffJacobson added a commit to WSDOT-GIS/wsdot-mp-map that referenced this issue May 21, 2024
build: :down_arrow: Downgraded lefthook dependency due to issues

Reverted to the previous version of lefthook due to it not working.
That newer version was also being detected as a virus.
(See evilmartians/lefthook#722)

My issue could possibly be related to this one:
- evilmartians/lefthook#708
JeffJacobson added a commit to WSDOT-GIS/wsdot-mp-map that referenced this issue May 21, 2024
* feat: ✨ Added WSDOT logo to header

* build: ➕ Added @wsdot/web-styles dependency
* build: :down_arrow: Downgraded lefthook dependency due to issues

Reverted to the previous version of lefthook due to it not working.
That newer version was also being detected as a virus.
(See evilmartians/lefthook#722)

My issue could possibly be related to this one:
- evilmartians/lefthook#708
inetol added a commit to JSPaste/Frontend that referenced this issue May 29, 2024
inetol added a commit to JSPaste/Backend that referenced this issue May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants