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

Failed to install usb-detection in windows-latest environment #280

Closed
kiruh opened this issue Jul 2, 2021 · 8 comments
Closed

Failed to install usb-detection in windows-latest environment #280

kiruh opened this issue Jul 2, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@kiruh
Copy link

kiruh commented Jul 2, 2021

When I run npm install in GitHub Actions windows-latest environment I get following error

npm ERR! D:\a\cs\cs\electron\node_modules\usb-detection\src\detection.h(5,10): fatal error C1083: Cannot open include file: 'node.h': No such file or directory [D:\a\cs\cs\electron\node_modules\usb-detection\build\detection.vcxproj]

Interesting is that each time I run the workflow I get different errors or no errors at all and install succeeds

What's common is that if install fails it does on node-gyp rebuild command

node-gyp rebuild is called by usb-detection and @serialport/bindings packages in their install scripts

It looks like node-gyp fails to find some files, e.g. node.h, v8.h, common.gypi

It is really hard to debug it since the outcome alters with each run

Any suggestions on what may be a reason of it?

Workflow

release_on_windows:
  runs-on: windows-latest

  steps:
    - uses: actions/checkout@master

    - uses: actions/setup-node@master
      with:
        node-version: 14

    - run: npm install

Dependencies

  "dependencies": {
    "@sentry/electron": "^2.4.1",
    "electron-updater": "^4.3.9",
    "electron-window-state": "^5.0.3",
    "serialport": "^9.0.7",
    "usb-detection": "^4.10.0"
  },
  "devDependencies": {
    "@sentry/cli": "^1.65.0",
    "cross-env": "^7.0.3",
    "electron": "^12.0.9",
    "electron-builder": "^22.9.1",
    "electron-download": "^4.1.1"
  }

Error examples

npm ERR! C:\Users\runneradmin\.electron-gyp\12.0.9\include\node\node.h(67,10): fatal error C1083: Cannot open include file: 'v8.h': No such file or directory [D:\a\cs\cs\electron\node_modules\usb-detection\build\detection.vcxproj]
npm ERR! gyp: C:\Users\runneradmin\AppData\Local\node-gyp\Cache\14.17.1\common.gypi not found (cwd: D:\a\cs\cs\electron\node_modules\usb-detection) while reading includes of binding.gyp while trying to load binding.gyp
npm ERR! gyp: C:\Users\runneradmin\.electron-gyp\12.0.9\common.gypi not found (cwd: D:\a\cs\cs\electron\node_modules\@serialport\bindings) while reading includes of binding.gyp while trying to load binding.gyp

Log example

Run npm install
  npm install
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

> swimcloud-meet@0.1.6 postinstall
> electron-builder install-app-deps

  • electron-builder  version=22.10.5
  • loaded configuration  file=package.json ("build" field)
  • rebuilding native dependencies  dependencies=@serialport/bindings@9.0.7, usb-detection@4.10.0 platform=win32 arch=x64
  • install prebuilt binary  name=@serialport/bindings version=9.0.7 platform=win32 arch=x64
  • build native dependency from sources  name=@serialport/bindings
                                          version=9.0.7
                                          platform=win32
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 6.1.2
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for local prebuild @ prebuilds\bindings-v9.0.7-electron-v87-win32-x64.tar.gz
    prebuild-install info looking for cached prebuild @ C:\npm\cache\_prebuilds\e02868-bindings-v9.0.7-electron-v87-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@9.0.7/bindings-v9.0.7-electron-v87-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@9.0.7/bindings-v9.0.7-electron-v87-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=12.0.9 runtime=electron arch=x64 libc= platform=win32)
    
  • install prebuilt binary  name=usb-detection version=4.10.0 platform=win32 arch=x64
  • build native dependency from sources  name=usb-detection
                                          version=4.10.0
                                          platform=win32
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 6.1.2
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for local prebuild @ prebuilds\usb-detection-v4.10.0-electron-v87-win32-x64.tar.gz
    prebuild-install info looking for cached prebuild @ C:\npm\cache\_prebuilds\bd48fa-usb-detection-v4.10.0-electron-v87-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/MadLittleMods/node-usb-detection/releases/download/v4.10.0/usb-detection-v4.10.0-electron-v87-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/MadLittleMods/node-usb-detection/releases/download/v4.10.0/usb-detection-v4.10.0-electron-v87-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=12.0.9 runtime=electron arch=x64 libc= platform=win32)
    
  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path D:\a\cs\cs\electron\node_modules\usb-detection
    npm ERR! command failed
    npm ERR! command C:\Windows\system32\cmd.exe /d /s /c prebuild-install || node-gyp rebuild
    npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
    npm ERR!   detection.cpp
    npm ERR! D:\a\cs\cs\electron\node_modules\usb-detection\src\detection.h(5,10): fatal error C1083: Cannot open include file: 'node.h': No such file or directory [D:\a\cs\cs\electron\node_modules\usb-detection\build\detection.vcxproj]
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@7.1.2
    npm ERR! gyp info using node@14.17.1 | win32 | x64
    npm ERR! gyp info find Python using Python version 3.7.9 found at "C:\hostedtoolcache\windows\Python\3.7.9\x64\python3.exe"
    npm ERR! gyp http GET https://electronjs.org/headers/v12.0.9/node-v12.0.9-headers.tar.gz
    npm ERR! gyp http 200 https://electronjs.org/headers/v12.0.9/node-v12.0.9-headers.tar.gz
    npm ERR! gyp http GET https://electronjs.org/headers/v12.0.9/SHASUMS256.txt
    npm ERR! gyp http GET https://electronjs.org/headers/v12.0.9/win-x86/node.lib
    npm ERR! gyp http GET https://electronjs.org/headers/v12.0.9/win-x64/node.lib
    npm ERR! gyp http GET https://electronjs.org/headers/v12.0.9/win-arm64/node.lib
    npm ERR! gyp http 200 https://electronjs.org/headers/v12.0.9/SHASUMS256.txt
    npm ERR! gyp http 200 https://electronjs.org/headers/v12.0.9/win-x86/node.lib
    npm ERR! gyp http 200 https://electronjs.org/headers/v12.0.9/win-x64/node.lib
    npm ERR! gyp http 200 https://electronjs.org/headers/v12.0.9/win-arm64/node.lib
    npm ERR! gyp info find VS using VS2019 (16.10.31410.357) found at:
    npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"
    npm ERR! gyp info find VS run with --verbose for detailed information
    npm ERR! gyp info spawn C:\hostedtoolcache\windows\Python\3.7.9\x64\python3.exe
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   'C:\\npm\\prefix\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
    npm ERR! gyp info spawn args   'binding.gyp',
    npm ERR! gyp info spawn args   '-f',
    npm ERR! gyp info spawn args   'msvs',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'D:\\a\\cs\\cs\\electron\\node_modules\\usb-detection\\build\\config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\npm\\prefix\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\Users\\runneradmin\\.electron-gyp\\12.0.9\\include\\node\\common.gypi',
    npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
    npm ERR! gyp info spawn args   '-Dvisibility=default',
    npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\runneradmin\\.electron-gyp\\12.0.9',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\npm\\prefix\\node_modules\\npm\\node_modules\\node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\runneradmin\\\\.electron-gyp\\\\12.0.9\\\\<(target_arch)\\\\node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=D:\\a\\cs\\cs\\electron\\node_modules\\usb-detection',
    npm ERR! gyp info spawn args   '-Dnode_engine=v8',
    npm ERR! gyp info spawn args   '--depth=.',
    npm ERR! gyp info spawn args   '--no-parallel',
    npm ERR! gyp info spawn args   '--generator-output',
    npm ERR! gyp info spawn args   'D:\\a\\cs\\cs\\electron\\node_modules\\usb-detection\\build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   'build/binding.sln',
    npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
    npm ERR! gyp info spawn args   '/nologo',
    npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp ERR! build error 
    npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\npm\prefix\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:375:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
    npm ERR! gyp ERR! System Windows_NT 10.0.17763
    npm ERR! gyp ERR! command "C:\\hostedtoolcache\\windows\\node\\14.17.1\\x64\\node.exe" "C:\\npm\\prefix\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
    npm ERR! gyp ERR! cwd D:\a\cs\cs\electron\node_modules\usb-detection
    npm ERR! gyp ERR! node -v v14.17.1
    npm ERR! gyp ERR! node-gyp -v v7.1.2
    npm ERR! gyp ERR! not ok
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\npm\cache\_logs\2021-06-25T13_32_38_595Z-debug.log
    
                    command='C:\hostedtoolcache\windows\node\14.17.1\x64\node.exe' 'C:\npm\prefix\node_modules\npm\bin\npm-cli.js' rebuild @serialport/bindings@9.0.7 usb-detection@4.10.0
                    workingDir=
npm ERR! code 1
npm ERR! path D:\a\cs\cs\electron
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c electron-builder install-app-deps

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\2021-06-25T13_32_38_662Z-debug.log
Error: Process completed with exit code 1.
@dmitry-shibanov
Copy link
Contributor

Hello @kiruh. I've tested your package.json and it looks like everything works as expected. Could you please confirm if it works for you ?

@kiruh
Copy link
Author

kiruh commented Oct 18, 2021

Hello @kiruh. I've tested your package.json and it looks like everything works as expected. Could you please confirm if it works for you ?

Yes, it works for now. There were no failing builds for some time.

I hope this behavior persists since that problem wouldn't occur each time before 🤷 One time run would be successful, the other it would fail.

I suppose issue can be closed for now and if it continues to fail I'll reopen it.

@kiruh kiruh closed this as completed Oct 18, 2021
@kiruh
Copy link
Author

kiruh commented May 13, 2022

Failed to build @serialport/bindings on windows-latest (windows-2022) again.

Although the problem now is different:

gyp ERR! stack Error: Could not find any Visual Studio installation to use

Learn more


💡 The good thing is that it works when I switch it back to windows-2019. That's a workaround for now.

@IvanZosimov
Copy link
Contributor

Hi, @kiruh 👋 ! I've tested your case with windows-latest and it seems the problem is gone. Could you, please, check it on your side and ping me about the situation?

Cheers!

@kiruh
Copy link
Author

kiruh commented May 25, 2022

Hi @IvanZosimov,

The problem is still there.

package.json

{
  "name": "my-app-name",
  "version": "0.1.0",
  "scripts": {
    "postinstall": "electron-builder install-app-deps"
  },
  "dependencies": {
    "serialport": "^9.0.7",
    "usb-detection": "^4.13.0"
  },
  "devDependencies": {
    "electron": "^12.0.9",
    "electron-builder": "^22.9.1"
  }
}

workflow.yml

name: Workflow

on: workflow_dispatch

defaults:
  run:
    working-directory: electron

jobs:
  release_on_windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@master

      - uses: actions/setup-node@master
        with:
          node-version: 14

      - name: Install dependencies
        run: npm install

Log

##[group]Run npm install
�[36;1mnpm install�[0m
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
##[endgroup]
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

> @serialport/bindings@9.2.8 install D:\a\cs\cs\electron\node_modules\@serialport\bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild


> usb-detection@4.13.0 install D:\a\cs\cs\electron\node_modules\usb-detection
> prebuild-install || node-gyp rebuild


> core-js@3.12.1 postinstall D:\a\cs\cs\electron\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> electron@12.2.3 postinstall D:\a\cs\cs\electron\node_modules\electron
> node install.js


> my-app-name@0.1.0 postinstall D:\a\cs\cs\electron
> electron-builder install-app-deps

  • electron-builder  version=22.10.5
  • rebuilding native dependencies  dependencies=@serialport/bindings@9.2.8, usb-detection@4.13.0 platform=win32 arch=x64
  • install prebuilt binary  name=@serialport/bindings version=9.2.8 platform=win32 arch=x64
  • build native dependency from sources  name=@serialport/bindings
                                          version=9.2.8
                                          platform=win32
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 6.1.4
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for local prebuild @ prebuilds\bindings-v9.2.8-electron-v87-win32-x64.tar.gz
    prebuild-install info looking for cached prebuild @ C:\npm\cache\_prebuilds\b1a069-bindings-v9.2.8-electron-v87-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@9.2.8/bindings-v9.2.8-electron-v87-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@9.2.8/bindings-v9.2.8-electron-v87-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=12.2.3 runtime=electron arch=x64 libc= platform=win32)

  • install prebuilt binary  name=usb-detection version=4.13.0 platform=win32 arch=x64
  ⨯ cannot execute  cause=exit status 1
                    out=
    > @serialport/bindings@9.2.8 install D:\a\cs\cs\electron\node_modules\@serialport\bindings
    > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild


    D:\a\cs\cs\electron\node_modules\@serialport\bindings>if not defined npm_config_node_gyp (node "C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

                    errorOut=prebuild-install WARN install No prebuilt binaries found (target=12.2.3 runtime=electron arch=x64 libc= platform=win32)
    gyp ERR! find VS
    gyp ERR! find VS msvs_version not set from command line or npm config
    gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
    gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
    gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
    gyp ERR! find VS looking for Visual Studio 2015
    gyp ERR! find VS - not found
    gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
    gyp ERR! find VS
    gyp ERR! find VS **************************************************************
    gyp ERR! find VS You need to install the latest version of Visual Studio
    gyp ERR! find VS including the "Desktop development with C++" workload.
    gyp ERR! find VS For more information consult the documentation at:
    gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
    gyp ERR! find VS **************************************************************
    gyp ERR! find VS
    gyp ERR! configure error
    gyp ERR! stack Error: Could not find any Visual Studio installation to use
    gyp ERR! stack     at VisualStudioFinder.fail (C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
    gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
    gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
    gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
    gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
    gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
    gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
    gyp ERR! stack     at ChildProcess.exithandler (child_process.js:390:5)
    gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
    gyp ERR! stack     at maybeClose (internal/child_process.js:1088:16)
    gyp ERR! System Windows_NT 10.0.20348
    gyp ERR! command "C:\\hostedtoolcache\\windows\\node\\14.19.3\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\14.19.3\\x64\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
    gyp ERR! cwd D:\a\cs\cs\electron\node_modules\@serialport\bindings
    gyp ERR! node -v v14.19.3
    gyp ERR! node-gyp -v v5.1.0
    gyp ERR! not ok
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! @serialport/bindings@9.2.8 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the @serialport/bindings@9.2.8 install script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\npm\cache\_logs\2022-05-25T11_40_45_906Z-debug.log

                    command='C:\hostedtoolcache\windows\node\14.19.3\x64\node.exe' 'C:\hostedtoolcache\windows\node\14.19.3\x64\node_modules\npm\bin\npm-cli.js' rebuild @serialport/bindings@9.2.8
                    workingDir=
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app-name@0.1.0 postinstall: `electron-builder install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app-name@0.1.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\2022-05-25T11_40_46_021Z-debug.log
##[error]Process completed with exit code 1.

@IvanZosimov
Copy link
Contributor

IvanZosimov commented May 27, 2022

Hi, @kiruh 👋 ! The root cause of your problem is in the version of the node-gyp. The thing is that the version which is bundled in npm is too outdated (in your case it's v5.1.0). Such an old version simply doesn't support VS2022, which is the only version of the VS installed on the windows-latest image. This problem is met very often by customers of the node-gyp, so the maintainers of the node-gyp created a special manual describing how to update its version. Below you can find the workaround which was created with reference to the manual I mentioned above:

- name: Update node-gyp
   run: |
     $WhereNode = Get-Command node | Select-Object -ExpandProperty Definition
     $NodeDirPath = Split-Path $WhereNode -Parent
     $NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\npm-lifecycle"
     cd $NodeModulesPath
     npm install node-gyp@8.x

Could you, please, ping me if everything is OK?

@IvanZosimov IvanZosimov self-assigned this May 27, 2022
@kiruh
Copy link
Author

kiruh commented May 27, 2022

Hi @IvanZosimov,

Yes, it works!

Thank you 🎉


Final Result

workflow.yml

name: Workflow

on: workflow_dispatch

jobs:
  release_on_windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@master

      - uses: actions/setup-node@master
        with:
          node-version: 14

      - name: Update node-gyp
        run: |
          $WhereNode = Get-Command node | Select-Object -ExpandProperty Definition
          $NodeDirPath = Split-Path $WhereNode -Parent
          $NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\npm-lifecycle"
          cd $NodeModulesPath
          npm install node-gyp@8.x

      - name: Install dependencies
        run: npm install

@verhovsky
Copy link

verhovsky commented Mar 9, 2023

I have a related issue.

My matrix is Node 14, 16, 18 with ubuntu-latest, macos-latest and windows-latest. I'm able to build with prebuild and run tests on Ubuntu and macOS with all node versions, but I have issues on Windows.

I have an "overrides" in my package.json which should cause Node to use node-gyp 9

https://github.com/verhovsky/node-tree-sitter/blob/78329b24971b062b1dd1ddcc4dd9339e57ed5481/package.json#L30-L34

, it seems to work on Node 16 and 18 but on Node 14 I was getting the same error as in the issue and it was using node-gyp 5

verhovsky/node-tree-sitter@98276a6

https://github.com/verhovsky/node-tree-sitter/actions/runs/4377505882/jobs/7661070137

gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\hostedtoolcache\windows\node\14.21.3\x64\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:390:5)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at maybeClose (internal/child_process.js:1088:16)
gyp ERR! System Windows_NT 10.0.20348
gyp ERR! command "C:\\hostedtoolcache\\windows\\node\\14.21.3\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\14.21.3\\x64\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\a\node-tree-sitter\node-tree-sitter\node_modules\superstring
gyp ERR! node -v v14.21.3
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win[32](https://github.com/verhovsky/node-tree-sitter/actions/runs/4377505882/jobs/7661070137#step:4:33)","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! superstring@2.4.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the superstring@2.4.4 install script.

after adding the lines suggested in the issue it works, however on Node 16 and 18 I got this error

https://github.com/verhovsky/node-tree-sitter/actions/runs/4377590661/jobs/7661258077

Set-Location: D:\a\_temp\56bea9ba-bab1-4034-8422-84ca97f07713.ps1:5
Line |
   5 |  cd $NodeModulesPath
     |  ~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'C:\hostedtoolcache\windows\node\16.1[9](https://github.com/verhovsky/node-tree-sitter/actions/runs/4377590661/jobs/7661258077#step:4:10).1\x64\node_modules\npm\node_modules\npm-lifecycle'
     | because it does not exist.

Error: Process completed with exit code 1.

so I changed my if: to

        if: ${{ matrix.os == 'windows-latest' && matrix.node == '14' }}

and now windows+node 14 passes but windows+node 16 and windows+node 18 show this error (they run node-gyp 9):

npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@16.19.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.13 found at "C:\hostedtoolcache\windows\Python\3.9.13\x[64](https://github.com/verhovsky/node-tree-sitter/actions/runs/4377712086/jobs/7661533378#step:5:65)\python3.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.1/node-v16.19.1-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.19.1/node-v16.19.1-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.1/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.1/win-x86/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.1/win-x64/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.1/win-arm64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.19.1/SHASUMS256.txt
npm ERR! gyp http 404 https://nodejs.org/download/release/v16.19.1/win-arm64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.19.1/win-x64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.19.1/win-x86/node.lib
npm ERR! gyp info find VS using VS2022 (17.5.33424.131) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\hostedtoolcache\windows\Python\3.9.13\x64\python3.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\hostedtoolcache\\windows\\node\\16.19.1\\x64\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\npm\\cache\\_cacache\\tmp\\git-clone50gJ3G\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\hostedtoolcache\\windows\\node\\16.19.1\\x64\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\runneradmin\\AppData\\Local\\node-gyp\\Cache\\16.19.1\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\runneradmin\\AppData\\Local\\node-gyp\\Cache\\16.19.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\hostedtoolcache\\windows\\node\\16.19.1\\x64\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.19.1\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\npm\\cache\\_cacache\\tmp\\git-clone50gJ3G',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\npm\\cache\\_cacache\\tmp\\git-clone50gJ3G\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\hostedtoolcache\windows\node\16.19.1\x64\node_modules\npm\node_modules\node-gyp\lib\build.js:201:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:2[93](https://github.com/verhovsky/node-tree-sitter/actions/runs/4377712086/jobs/7661533378#step:5:94):12)
npm ERR! gyp ERR! System Windows_NT 10.0.20348
npm ERR! gyp ERR! command "C:\\hostedtoolcache\\windows\\node\\16.19.1\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\16.19.1\\x64\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\npm\cache\_cacache\tmp\git-clone50gJ3G
npm ERR! gyp ERR! node -v v16.19.1
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok 
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path C:\npm\cache\_cacache\tmp\git-clone50gJ3G
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild

I tried doing npm install --production windows-build-tools and npm install --production windows-build-tools@4.0.0 just for those versions as suggested here: nodejs/node-gyp#119 (comment) and it didn't let me run that command

https://github.com/verhovsky/node-tree-sitter/actions/runs/4378111273/jobs/7662433833

npm ERR! Downloaded vs_BuildTools.exe. Saved to C:\Users\runneradmin\.windows-build-tools\vs_BuildTools.exe.
npm ERR! 
npm ERR! Starting installation...
npm ERR! Downloading installers failed. Error: TypeError: 'process.env' only accepts a configurable, writable, and enumerable data descriptor
npm ERR!     at Function.defineProperty (<anonymous>)
npm ERR!     at Object.removePath (D:\a\node-tree-sitter\node-tree-sitter\node_modules\windows-build-tools\dist\utils\remove-path.js:11:12)
npm ERR!     at Object.install (D:\a\node-tree-sitter\node-tree-sitter\node_modules\windows-build-tools\dist\install\index.js:29:19)
npm ERR!     at D:\a\node-tree-sitter\node-tree-sitter\node_modules\windows-build-tools\dist\start.js:17:19
npm ERR!     at Object.download (D:\a\node-tree-sitter\node-tree-sitter\node_modules\windows-build-tools\dist\download.js:35:5)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR!     at async Object.aquireInstallers (D:\a\node-tree-sitter\node-tree-sitter\node_modules\windows-build-tools\dist\aquire-installers.js:32:13) {
npm ERR!   code: 'ERR_INVALID_OBJECT_DEFINE_PROPERTY'
npm ERR! }
npm ERR! windows-build-tools will now exit.

deining pushed a commit to deining/setup-node that referenced this issue Nov 9, 2023
* feat: add pathspec_error_handling input

* fix: show add/rm errors on same line

* docs(README): add docs for new input
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