node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

Electron with serialport npm install fails with node-gyp error code

Open Ematusz opened this issue 4 years ago • 2 comments

  • Node Version: v16.13.0
  • Platform: Windows 10, 10.0.19042 64bit
  • Compiler: Visual Studio Community 2019 (executed npm config set msvs_version 2019)
  • Module: serialport
  • Python: 3.9.7
Verbose output (from npm or node-gyp):
>npm ERR! code 1
npm ERR! path C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c prebuild-install --tag-prefix @serialport/bindings@ || 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!   serialport.cpp
npm ERR! C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\src\serialport.cpp(329,96): error C2661: 'v8::Object::Set': no overloaded function takes 2 arguments [C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\build\bindings.vcxproj]
npm ERR! C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\src\serialport.cpp(330,96): error C2661: 'v8::Object::Set': no overloaded function takes 2 arguments [C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\build\bindings.vcxproj]
npm ERR! C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\src\serialport.cpp(331,96): error C2661: 'v8::Object::Set': no overloaded function takes 2 arguments [C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\build\bindings.vcxproj]
npm ERR! C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\src\serialport.cpp(378,106): error C2661: 'v8::Object::Set': no overloaded function takes 2 arguments [C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings\build\bindings.vcxproj]
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "C:\Users\Test\AppData\Local\Programs\Python\Python39\python.exe"
npm ERR! gyp info find VS using VS2019 (16.11.31729.503) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\Test\AppData\Local\Programs\Python\Python39\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\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:\\Users\\Test\\electron-serialport-quick-start\\node_modules\\@serialport\\bindings\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\Test\\AppData\\Local\\node-gyp\\Cache\\16.13.0\\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\\Test\\AppData\\Local\\node-gyp\\Cache\\16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\Test\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.13.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\Test\\electron-serialport-quick-start\\node_modules\\@serialport\\bindings',
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:\\Users\\Test\\electron-serialport-quick-start\\node_modules\\@serialport\\bindings\\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\Community\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\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\Test\electron-serialport-quick-start\node_modules\@serialport\bindings
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.2.0
npm ERR! gyp ERR! not ok

Usage: npm install

Hello, I have been struggling with this issue for quite some time at this point so any help would be greatly appreciated. I seem to be having trouble with node-gyp when I try to install native node modules. I have been working on a project that was working completely fine until a few days ago when I was trying to resolve some dependency vulnerabilities. I seem to have messed up my environment now to the point where I cannot build a project with any native node modules. Specifically, I have been working with serialport. I went back to their demo project in an attempt to isolate the problem as much as possible, but I still get this error when I try to run npm install.

Steps I have taken to resolve:

  • Uninstall and reinstall Node multiple times with multiple versions
  • Uninstall and reinstall windows-build-tools and Microsoft Visual Stuio community multiple times with multiple versions
  • Update node-gyp
  • Uninstall and reinstall python multiple times with multiple versions

I know everything was working fine last week. I tried to scrub everything I could out of my electron environment and set it all back up from scratch but I am still getting errors. Any suggestions would be very much appreciated. Also, happy to provide any additional information that I did not think to add.

Ematusz avatar Nov 04 '21 20:11 Ematusz

Hello everyone, I have the same problem on my Mac machine Monterey. I'm using 16th version of node. And when I try install packages via sudo npm i - I get the following errors:

npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release/canvas.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v93-darwin-unknown-arm64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v93-darwin-unknown-arm64.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v93 ABI, unknown) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v93-darwin-unknown-arm64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.7 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/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   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/railbatyrshin/Library/Caches/node-gyp/16.13.0/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=/Users/railbatyrshin/Library/Caches/node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/railbatyrshin/Library/Caches/node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas',
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   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Package pangocairo was not found in the pkg-config search path.
npm ERR! Perhaps you should add the directory containing `pangocairo.pc'
npm ERR! to the PKG_CONFIG_PATH environment variable
npm ERR! No package 'pangocairo' found
npm ERR! gyp: Call to 'pkg-config pangocairo --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack
at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.1.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.1.0
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/railbatyrshin/Desktop/mywork/maddevs/node_modules/canvas
npm ERR! node-pre-gyp ERR! node -v v16.13.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.6
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/railbatyrshin/.npm/_logs/2021-11-11T06_16_55_608Z-debug.log

TangoPJ avatar Nov 11 '21 06:11 TangoPJ

For me it solved that problem to install node with x86 instead of standard arm64. @TangoPJ I can see from your error message that you installed node under arm64. Just follow that steps https://github.com/nvm-sh/nvm/issues/2350#issuecomment-753257403 Hope that helps.

MaLIE2018 avatar Dec 06 '21 10:12 MaLIE2018

@TangoPJ node-pre-gyp is unmaintained.

cclauss avatar Apr 11 '24 12:04 cclauss

This issue seems no longer relevant as it uses a no longer supported version of Node. If there are no objections, I will close this issue next Mon-Tue. In case something similar happens again please open a new issue.

StefanStojanovic avatar Apr 17 '24 12:04 StefanStojanovic