1

When running cy run (via npm run test:e2e) from the terminal it works just fine. The same command added to husky pre-push results in the following error:

Error: Cannot find module '/Users/me/Library/Caches/Cypress/10.3.1/Cypress.app/Contents/MacOS/Contents/Resources/app/index.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

My .husky/pre-push file looks like this:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run test
npm run test:e2e

I cannot replicate the error via the terminal. Why is this error only happening with husky and how can I solve it?

  • Platform: MacOS
  • Node version: 16.14.2
  • Cypress version: 10.3.1
Terrabythia
  • 2,031
  • 3
  • 19
  • 29

1 Answers1

0

I had the same issue when using VSCode (I'm assuming you are as well), when trying to commit from VSCode UI.

When running from the command line using git commit - it works fine.

The answer may be an issue with Husky/VSCode similar to Husky 4.x+ not working with Visual Studio Git