electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

Windows-Build fails: spawn node-gyp ENOENT

Open Jones-S opened this issue 7 months ago • 5 comments

  • Electron-Builder: ^24.6.4:
  • Node: v18.18.2:
  • Electron: ^27.0.4:
  • Electron Type (current, beta, nightly):

None

  • Target: Windows:

I am trying to build for windows target, and it worked until last week. Until then I was on node v16, due to a package I needed in my app, I needed to upgrade to 18. Now If I use:

$ electron-builder build --win --ia32 --x64

I get

node:events:495
          throw er; // Unhandled 'error' event
          ^
    
    Error: spawn node-gyp ENOENT
        at ChildProcess._handle.onexit (node:internal/child_process:284:19)
        at onErrorNT (node:internal/child_process:477:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    Emitted 'error' event on ChildProcess instance at:
        at ChildProcess._handle.onexit (node:internal/child_process:290:12)
        at onErrorNT (node:internal/child_process:477:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
      errno: -2,
      code: 'ENOENT',
      syscall: 'spawn node-gyp',
      path: 'node-gyp',
      spawnargs: [ 'rebuild' ]
    }
    
    Node.js v18.18.2
error Command failed with exit code 1.
    
                    command=/Users/USER/.nvm/versions/node/v18.18.2/bin/node /Users/USER/.nvm/versions/node/v18.18.2/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/Users/USER/Documents/github/USER-s/PROJET/node_modules/@serialport/bindings-cpp
error Command failed with exit code 1.

I tried to install node-gyp globally via npm -g install node-gyp, because I read that online. That did not work though...

I also tried to run electron-builder install-app-deps with no effect.

Any ideas? Thank you a lot

Best

Jones-S avatar Nov 28 '23 09:11 Jones-S

I switched to node v20, installed all packages and app-deps and it worked. Nonetheless I would be interested what the problem is.

Jones-S avatar Nov 28 '23 09:11 Jones-S

Same problem here with 18.18.2.

      - uses: actions/setup-node@v3
        with:
-          node-version: 18
+          node-version: 18.17.1
          cache: 'yarn'

Needed to force a "working" node version.

Error log with 18.18.2 and electron builder 23.3.3

image
  • rebuilding native dependencies  [email protected] platform=win32 arch=ia32
  • rebuilding native dependency  name=usb version=2.5.0
  ⨯ cannot execute  cause=exit status 1
                    out=$ node-gyp-build
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

                    errorOut=node:events:495
          throw er; // Unhandled 'error' event
          ^
    
    Error: spawn node-gyp.cmd ENOENT
        at ChildProcess._handle.onexit (node:internal/child_process:284:19)
        at onErrorNT (node:internal/child_process:477:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    Emitted 'error' event on ChildProcess instance at:
        at ChildProcess._handle.onexit (node:internal/child_process:290:12)
        at onErrorNT (node:internal/child_process:477:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
      errno: -4058,
      code: 'ENOENT',
      syscall: 'spawn node-gyp.cmd',
      path: 'node-gyp.cmd',
      spawnargs: [ 'rebuild' ]
    }
    
    Node.js v18.18.2
    error Command failed with exit code 1.
    
                    command='C:\hostedtoolcache\windows\node\18.18.2\x64\node.exe' 'C:\npm\prefix\node_modules\yarn\bin\yarn.js' run install
                    workingDir=D:\a\merchant-portal\merchant-portal\node_modules\usb
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

yooouuri avatar Nov 28 '23 10:11 yooouuri

Same issue building Linux apps with the latest electronuserland/builder:18 (Node 18.18.2) Docker image:

    Error: spawn node-gyp ENOENT
    {
       errno: -2,
       code: 'ENOENT',
       syscall: 'spawn node-gyp',
       path: 'node-gyp',
       spawnargs: [ 'rebuild' ]
    }

Everything works using electronuserland/builder:18-07.23 (Node 18.15.0)

jzecca avatar Dec 11 '23 10:12 jzecca

This seems like an incompatibility of node-gyp versus the updated node version. Not sure if I can do anything here from electron-builders side (since it doesn't configure node-gyp, simply executes rebuild) other than maybe upgrading node in the docker image to latest (18.19.0). Can you test on your CI/CD if that node version resolves the issue?

mmaietta avatar Jan 12 '24 18:01 mmaietta

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 13 '24 00:03 github-actions[bot]