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

Unable to build binary modules on windows-latest #68

Closed
reconbot opened this issue Sep 28, 2019 · 8 comments
Closed

Unable to build binary modules on windows-latest #68

reconbot opened this issue Sep 28, 2019 · 8 comments

Comments

@reconbot
Copy link

reconbot commented Sep 28, 2019

I think this is just a path issue. As part of node serialport's test process I need to ensure we can build the binary. I run node-gyp rebuild on the binary package and I get the following error.

gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe ENOENT

full stack below

D:\a\node-serialport\node-serialport\packages\bindings>if not defined npm_config_node_gyp (node "C:\hostedtoolcache\windows\node\8.10.0\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\8.10.0\x64\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) 

lerna ERR! npm install stderr:
gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at _errnoException (util.js:1022:11)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:372:16)
gyp ERR! stack     at _combinedTickCallback (internal/process/next_tick.js:138:11)
gyp ERR! stack     at process._tickCallback (internal/process/next_tick.js:180:9)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\hostedtoolcache\\windows\\node\\8.10.0\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\8.10.0\\x64\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\a\node-serialport\node-serialport\packages\bindings
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! This is a bug in `node-gyp`.

https://github.com/serialport/node-serialport/runs/240073493

@reconbot
Copy link
Author

Turns out this is an issue with node-gyp and visual studio 2019.

After coming through some steps here nodejs/node-gyp#1663 I was able to figure out a way through

    - name: patch node gyp on windows to support Visual Studio 2019
      shell: powershell
      run: |
        npm install --global node-gyp@latest
        npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}

I use a matrix for multiple OS's so I also have this line to only run it on windows.

      if: matrix.os == 'windows-latest'

@kiruh
Copy link

kiruh commented May 18, 2021

I tried this job but it's not working. Any suggestion what is wrong?

publish_on_windows:
  runs-on: windows-latest
  steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@master
      with:
        node-version: 14

    - name: Update npm
      run: npm install --global npm@latest

    - name: Patch node-gyp to support Visual Studio 2019
      shell: powershell
      run: |
        npm install --global node-gyp@latest
        npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}

    - name: Install npm dependencies
      run: npm install

    - name: Release
      run: npm run release

And I have the same error. I think some C headers are missing

@kiruh
Copy link

kiruh commented May 18, 2021

Error log

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 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! C:\Users\runneradmin\AppData\Local\node-gyp\Cache\14.16.1\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 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.16.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://nodejs.org/download/release/v14.16.1/node-v14.16.1-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v14.16.1/node-v14.16.1-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v14.16.1/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v14.16.1/win-x86/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v14.16.1/win-x64/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v14.16.1/win-arm64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v14.16.1/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v14.16.1/win-x64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v14.16.1/win-x86/node.lib
npm ERR! gyp http 404 https://nodejs.org/download/release/v14.16.1/win-arm64/node.lib
npm ERR! gyp info find VS using VS2019 (16.9.31205.134) 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\\AppData\\Local\\node-gyp\\Cache\\14.16.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\\14.16.1',
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\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.16.1\\\\<(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:315:20)
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.16.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.16.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-05-18T14_06_05_525Z-debug.log

@vladimiry
Copy link

vladimiry commented May 18, 2021

@kiruh I spent a lot of time trying to compile a native modules on windows-latest system but didn't succeed. What I ended up doing is installing vs 2017 which helped. Here is the installing script https://github.com/vladimiry/ElectronMail/blob/4104ef5bfe4dc613c68f3aef67264d67394475cb/scripts/ci/github/install-vs-build-tools.ps1 + its call https://github.com/vladimiry/ElectronMail/blob/4104ef5bfe4dc613c68f3aef67264d67394475cb/scripts/ci/github/package-app.ps1#L2-L3.

Updating node-gyp is also required in my case https://github.com/vladimiry/ElectronMail/blob/1d5955b80d705ce2a789fafa6c40198f32637986/scripts/ci/github/install-node-gyp.ps1#L1 but that's a little different story. It helps with compiling some native modules I use, but only some, not all of them.

Here is what gets installed by the above-referenced "install-vs-build-tools.ps1" script (installing takes ~ 3.5 minutes)
  InstanceId          : 2a98bf0b
  DisplayName         : Visual Studio Build Tools 2017
  InstallationVersion : 15.9.28307.1500
  InstallationPath    : C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
  InstallDate         : 5/6/2021 8:07:08 PM
  
  Id       : Microsoft.VisualStudio.Component.Windows81SDK
  Version  : 15.6.27406.0
  Chip     : 
  Language : 
  Branch   : 
  
  Ticks             : 2050333112
  Days              : 0
  Hours             : 0
  Milliseconds      : 33
  Minutes           : 3
  Seconds           : 25
  TotalDays         : 0.00237307073148148
  TotalHours        : 0.0569536975555556
  TotalMilliseconds : 205033.3112
  TotalMinutes      : 3.41722185333333
  TotalSeconds      : 205.0333112

@kiruh
Copy link

kiruh commented May 18, 2021

@vladimiry Thanks

@kiruh
Copy link

kiruh commented May 19, 2021

@reconbot can you post full version of working config?

@reconbot
Copy link
Author

@kiruh with node 14 I no longer have an issue but it looks like you need to npm install -g node-gyp@latest before installing your package to upgrade to work around the bug in older versions that shipped with npm. I'm unsure which version it was fixed in.

@kiruh
Copy link

kiruh commented Jul 2, 2021

@kiruh with node 14 I no longer have an issue but it looks like you need to npm install -g node-gyp@latest before installing your package to upgrade to work around the bug in older versions that shipped with npm. I'm unsure which version it was fixed in.

@reconbot I tried updating node-gyp but it didn't fix an issue

I described it in #280

krzyk pushed a commit to krzyk/setup-node that referenced this issue Apr 11, 2023
WEEPKRK-234: Fix logging path argument for newer Spring Boot versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants