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

Error: `gyp` failed with exit code: 1

Open TLXTDD opened this issue 3 years ago • 13 comments

Node Version: Node 12.22.12 and NPM 6.14.16 Node-Gyp Version: >= v9.1.0 Platform: Windows10 Module: node-gyp configure

gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_global\node_modules\node-gyp\lib\configure.js:284:16)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd C:\Users\tlx\Desktop\electron-quick-start-master\dll
gyp ERR! node -v v12.22.12
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok

TLXTDD avatar Aug 02 '22 09:08 TLXTDD

What command was typed?

Please include the FULL error log.

Node.js 12 is no longer supported. Please upgrade. https://nodejs.org/en/about/releases

cclauss avatar Aug 02 '22 09:08 cclauss

C:\Users\T\Desktop\electron-quick-start-master>node-gyp configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.5 found at "C:\Users\T\AppData\Local\Programs\Python\Python310\python.exe"
gyp http GET https://nodejs.org/download/release/v15.13.0/node-v15.13.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v15.13.0/node-v15.13.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v15.13.0/SHASUMS256.txt
gyp http GET https://nodejs.org/download/release/v15.13.0/win-x86/node.lib
gyp http GET https://nodejs.org/download/release/v15.13.0/win-arm64/node.lib
gyp http GET https://nodejs.org/download/release/v15.13.0/win-x64/node.lib
gyp http 200 https://nodejs.org/download/release/v15.13.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v15.13.0/win-x86/node.lib
gyp http 404 https://nodejs.org/download/release/v15.13.0/win-arm64/node.lib
gyp http 200 https://nodejs.org/download/release/v15.13.0/win-x64/node.lib
gyp info find VS using VS2017 (15.9.28307.2019) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Users\T\AppData\Local\Programs\Python\Python310\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\T\\Desktop\\electron-quick-start-master\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\T\\AppData\\Local\\node-gyp\\Cache\\15.13.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\T\\AppData\\Local\\node-gyp\\Cache\\15.13.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\T\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\15.13.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\T\\Desktop\\electron-quick-start-master',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\T\\Desktop\\electron-quick-start-master\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: binding.gyp not found (cwd: C:\Users\T\Desktop\electron-quick-start-master) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_global\node_modules\node-gyp\lib\configure.js:284:16)
gyp ERR! stack     at ChildProcess.emit (node:events:369:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd C:\Users\T\Desktop\electron-quick-start-master
gyp ERR! node -v v15.13.0
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok

TLXTDD avatar Aug 02 '22 09:08 TLXTDD

gyp: binding.gyp not found (cwd: C:\Users\T\Desktop\electron-quick-start-master) while trying to load binding.gyp

Please try to create an empty C:\Users\T\Desktop\electron-quick-start-master\binding.gyp file and run your command again.

cclauss avatar Aug 02 '22 09:08 cclauss

gyp: binding.gyp not found (cwd: C:\Users\T\Desktop\electron-quick-start-master) 尝试加载 binding.gyp

请尝试创建一个空C:\Users\T\Desktop\electron-quick-start-master\binding.gyp文件并再次运行您的命令。

The same problem occurs after the file is created

C:\Users\T\Desktop\electron-quick-start-master>node-gyp configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.5 found at "C:\Users\T\AppData\Local\Programs\Python\Python310\python.exe"
gyp info find VS using VS2017 (15.9.28307.2019) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Users\T\AppData\Local\Programs\Python\Python310\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\T\\Desktop\\electron-quick-start-master\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\T\\AppData\\Local\\node-gyp\\Cache\\16.16.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\T\\AppData\\Local\\node-gyp\\Cache\\16.16.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\T\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.16.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\T\\Desktop\\electron-quick-start-master',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\T\\Desktop\\electron-quick-start-master\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\gyp_main.py", line 45, in <module>
    sys.exit(gyp.script_main())
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 662, in script_main
    return main(sys.argv[1:])
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 654, in main
    return gyp_main(args)
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 621, in gyp_main
    [generator, flat_list, targets, data] = Load(
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 142, in Load
    result = gyp.input.Load(
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 3009, in Load
    LoadTargetBuildFile(
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 400, in LoadTargetBuildFile
    build_file_data = LoadOneBuildFile(
  File "C:\Program Files\nodejs\node_global\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 237, in LoadOneBuildFile
    build_file_data = eval(build_file_contents, {"__builtins__": {}}, None)
  File "binding.gyp", line 0

SyntaxError: invalid syntax
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_global\node_modules\node-gyp\lib\configure.js:284:16)
gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_global\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd C:\Users\T\Desktop\electron-quick-start-master
gyp ERR! node -v v16.16.0
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok

TLXTDD avatar Aug 02 '22 09:08 TLXTDD

This is not the same error. It is a different one. Now we need to figure out what to put in that binding.gyp file. @DeeDeeG @owl-from-hogvarts @VerteDinde Any ideas?

cclauss avatar Aug 02 '22 09:08 cclauss

Same issue here with Node 16 and Build Tools 2022:

λ node "C:\Users\agust\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | win32 | x64 gyp info find Python using Python version 3.10.6 found at "C:\Python310\python.exe" gyp info find VS using VS2022 (17.3.32819.101) found at: gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" gyp info find VS run with --verbose for detailed information gyp info spawn C:\Python310\python.exe gyp info spawn args [ gyp info spawn args 'C:\Users\agust\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'msvs', gyp info spawn args '-I', gyp info spawn args 'C:\Users\agust\git\tbx-live-logs-monitor\build\config.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\Users\agust\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\addon.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\Users\agust\AppData\Local\node-gyp\Cache\16.17.0\common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=C:\Users\agust\AppData\Local\node-gyp\Cache\16.17.0', gyp info spawn args '-Dnode_gyp_dir=C:\Users\agust\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp', gyp info spawn args '-Dnode_lib_file=C:\\Users\\agust\\AppData\\Local\\node-gyp\\Cache\\16.17.0\\<(target_arch)\\node.lib', gyp info spawn args '-Dmodule_root_dir=C:\Users\agust\git\tbx-live-logs-monitor', gyp info spawn args '-Dnode_engine=v8', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'C:\Users\agust\git\tbx-live-logs-monitor\build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] gyp: binding.gyp not found (cwd: C:\Users\agust\git\tbx-live-logs-monitor) while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (C:\Users\agust\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:284:16) gyp ERR! stack at ChildProcess.emit (node:events:513:28) gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) gyp ERR! System Windows_NT 10.0.19044 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\agust\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" gyp ERR! cwd C:\Users\agust\git\tbx-live-logs-monitor gyp ERR! node -v v16.17.0 gyp ERR! node-gyp -v v9.1.0 gyp ERR! not ok

agustincastanio avatar Aug 27 '22 13:08 agustincastanio

Same issue (Win11 & Node v16 & VisualStudio2019) I will also mention that the file node_modules/windows-utils/binding.gyp exists!

npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild 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:\Program Files\Python39\python.exe" npm ERR! gyp info find VS using VS2019 (16.11.31702.278) found at: npm ERR! gyp info find VS "D:\VisualStudio2019" npm ERR! gyp info find VS run with --verbose for detailed information npm ERR! gyp WARN read config.gypi ENOENT: no such file or directory, open 'C:\Users\Michal.electron-gyp\20.1.2\include\node\config.gypi' npm ERR! gyp info spawn C:\Program Files\Python39\python.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'D:\nvm\v16.15.1\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:\git_repos\pconline-desktop\node_modules\windows-utils\build\config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'D:\nvm\v16.15.1\node_modules\npm\node_modules\node-gyp\addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'C:\Users\Michal\.electron-gyp\20.1.2\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\Michal\.electron-gyp\20.1.2', npm ERR! gyp info spawn args '-Dnode_gyp_dir=D:\nvm\v16.15.1\node_modules\npm\node_modules\node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\Users\\Michal\\.electron-gyp\\20.1.2\\<(target_arch)\\node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=D:\git_repos\pconline-desktop\node_modules\windows-utils', 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:\git_repos\pconline-desktop\node_modules\windows-utils\build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp: C:\Users\Michal.electron-gyp\20.1.2\common.gypi not found (cwd: D:\git_repos\pconline-desktop\node_modules\windows-utils) while reading includes of 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 (D:\nvm\v16.15.1\node_modules\npm\node_modules\node-gyp\lib\configure.js:261:16) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) npm ERR! gyp ERR! System Windows_NT 10.0.22000 npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\nvm\v16.15.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd D:\git_repos\pconline-desktop\node_modules\windows-utils npm ERR! gyp ERR! node -v v16.15.1 npm ERR! gyp ERR! node-gyp -v v9.0.0 npm ERR! gyp ERR! not ok

michalzaq12 avatar Sep 08 '22 10:09 michalzaq12

For what it's worth, I think having an empty binding.gyp always produces the second error SyntaxError: invalid syntax when trying to read binding.gyp.

So that troubleshooting does not make the situation any more obvious to me.

It seems users in this thread are reporting errors when trying to use node-gyp in dirs that have no binding.gyp or invalid binding.gyp/common.gypi.

I really don't understand quite how gyp works in detail, but I don't think these projects have valid configuration to build with gyp in general?

DeeDeeG avatar Sep 11 '22 23:09 DeeDeeG

Could we go back to the original projects and add a failing GitHub Action (or other) test to demonstrate in their continuous integration that those projects do not work out-of-the-box?

cclauss avatar Sep 12 '22 06:09 cclauss

I removed <%app_data%>/Local/node-gyp/Cache, <%user%>/.electron-gyp, node_modules, package-lock.json then reinstalled all packages and it works now.

michalzaq12 avatar Sep 12 '22 13:09 michalzaq12

After getting the error unable to open v8-platform.h: No such file or directory. Finally I found the cause (this also applies to other <file> not found errors). Installing the Node SDK doesn't always work well on Windows. Some files are missing from the node directory. This is probably related to a problem with the tar package (used by node-gyp) https://github.com/npm/node-tar/blob/26a496e5fa74eeaa0c3539511560fc181ef56557/lib/unpack.js#L52 node-gyp

michalzaq12 avatar Oct 16 '22 15:10 michalzaq12

A possible easier solution could be to run: npx node-gyp install, which reinstalls node-gyp's copy of the C development headers for the running version of NodeJS.

(If you need to reinstall headers for a different version of NodeJS or Electron, more arguments may be needed. Such as npx node-gyp install 16.0.0 to [re]install headers for NodeJS 16.0.0... Or npx node-gyp install --dist-url=https://electronjs.org/headers 18.0.0 to install headers for Electron 18.0.0, I think.)

If this doesn't work, then @michalzaq12's comment above seems like a more thorough solution.

DeeDeeG avatar Nov 09 '22 21:11 DeeDeeG

Downgrading python version to 3.10 helped me: https://stackoverflow.com/a/74732671

losimen avatar Jun 03 '23 10:06 losimen

A possible easier solution could be to run: npx node-gyp install, which reinstalls node-gyp's copy of the C development headers for the running version of NodeJS.

(If you need to reinstall headers for a different version of NodeJS or Electron, more arguments may be needed. Such as npx node-gyp install 16.0.0 to [re]install headers for NodeJS 16.0.0... Or npx node-gyp install --dist-url=https://electronjs.org/headers 18.0.0 to install headers for Electron 18.0.0, I think.)

If this doesn't work, then @michalzaq12's comment above seems like a more thorough solution.

This worked for me, thanks!

joakimsjo avatar Jul 25 '23 07:07 joakimsjo

This issue seems no longer relevant as it uses a no longer supported version of Node and has been stale for some time. 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 18 '24 10:04 StefanStojanovic