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

electron 18.0.3 在 node-gyp编译有语法错误 #7

Closed
kidswong999 opened this issue May 10, 2022 · 4 comments
Closed

electron 18.0.3 在 node-gyp编译有语法错误 #7

kidswong999 opened this issue May 10, 2022 · 4 comments

Comments

@kidswong999
Copy link

测试系统:Windows10
node版本:v14.19.2
node-gyp版本:v5.1.0

虽然我不知道为什么会出错,可能和node版本有关。
但是electron更改为17.4.3可以解决。

错误log

c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2061: 语法错误: 标识符“TracedGlobal<`template-type-parameter-1'>” (编译源文件 ..\src\win\path_util.cc) [C:
\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\conpty.vcxproj]
  c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(335): note: 参见对正在编译的 类 模板 实例化 "v8::TracedGlobal<T>" 的引用 (编译源文件 ..\src\win\path_util.cc)
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2334: “:”的前面有意外标记;跳过明显的函数体 (编译源文件 ..\src\win\path_util.cc) [C:\Users\kaizhi\Desktop\singtown-c
am-ide\node_modules\node-pty\build\conpty.vcxproj]
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(22): fatal error C1075: “{”: 未找到匹配令牌 (编译源文件 ..\src\win\path_util.cc) [C:\Users\kaizhi\Desktop\singtown-cam-
ide\node_modules\node-pty\build\conpty.vcxproj]
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2061: 语法错误: 标识符“TracedGlobal<`template-type-parameter-1'>” (编译源文件 ..\src\win\conpty.cc) [C:\Us
ers\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\conpty.vcxproj]
  c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(335): note: 参见对正在编译的 类 模板 实例化 "v8::TracedGlobal<T>" 的引用 (编译源文件 ..\src\win\conpty.cc)c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2334: “:”的前面有意外标记;跳过明显的函数体 (编译源文件 ..\src\win\conpty.cc) [C:\Users\kaizhi\Desktop\singtown-cam-
ide\node_modules\node-pty\build\conpty.vcxproj]
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(22): fatal error C1075: “{”: 未找到匹配令牌 (编译源文件 ..\src\win\conpty.cc) [C:\Users\kaizhi\Desktop\singtown-cam-ide
\node_modules\node-pty\build\conpty.vcxproj]
  conpty_console_list.cc
  win_delay_load_hook.cc
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2061: 语法错误: 标识符“TracedGlobal<`template-type-parameter-1'>” (编译源文件 ..\src\win\conpty_console_li
st.cc) [C:\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\conpty_console_list.vcxproj]
  c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(335): note: 参见对正在编译的 类 模板 实例化 "v8::TracedGlobal<T>" 的引用 (编译源文件 ..\src\win\conpty_console_list.cc)
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2334: “:”的前面有意外标记;跳过明显的函数体 (编译源文件 ..\src\win\conpty_console_list.cc) [C:\Users\kaizhi\Desktop\
singtown-cam-ide\node_modules\node-pty\build\conpty_console_list.vcxproj]
c:\users\kaizhi\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(22): fatal error C1075: “{”: 未找到匹配令牌 (编译源文件 ..\src\win\conpty_console_list.cc) [C:\Users\kaizhi\Desktop\sin
gtown-cam-ide\node_modules\node-pty\build\conpty_console_list.vcxproj]
  AgentLocation.cc
  winpty.cc
  BackgroundDesktop.cc
  Buffer.cc
  DebugClient.cc
  GenRandom.cc
  OwnedHandle.cc
  StringUtil.cc
  WindowsSecurity.cc
  WindowsVersion.cc
  WinptyAssert.cc
  WinptyException.cc
  WinptyVersion.cc
  win_delay_load_hook.cc
    正在创建库 C:\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\Release\winpty.lib 和对象 C:\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\Release\winpty.exp
  winpty.vcxproj -> C:\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\Release\\winpty.dll
  Agent.cc
  AgentCreateDesktop.cc
  ConsoleFont.cc
  ConsoleInput.cc
  ConsoleInputReencoding.cc
  ConsoleLine.cc
  DebugShowInput.cc
  DefaultInputMap.cc
  EventLoop.cc
  InputMap.cc
  LargeConsoleRead.cc
  NamedPipe.cc
  Scraper.cc
  Terminal.cc
  Win32Console.cc
  Win32ConsoleBuffer.cc
  main.cc
  BackgroundDesktop.cc
  Buffer.cc
  GenRandom.cc
  OwnedHandle.cc
  StringUtil.cc
  WindowsSecurity.cc
  WindowsVersion.cc
  WinptyAssert.cc
  WinptyException.cc
  WinptyVersion.cc
  win_delay_load_hook.cc
  winpty-agent.vcxproj -> C:\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty\build\Release\\winpty-agent.exe
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Windows_NT 10.0.19043
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" "--openssl_fips=X" "--target=18.0.3" "--arch=x64" "--dist-url=https://electronjs.org/headers"
gyp ERR! cwd C:\Users\kaizhi\Desktop\singtown-cam-ide\node_modules\node-pty
gyp ERR! node -v v14.19.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
@bytemain
Copy link
Member

我们在 Windows 也遇到了这个问题,更新 VS C++ build tools 到 2019 及以上解决了。我们看看整体如何解决哈

@kidswong999
Copy link
Author

改了electron版本之后打包会有问题。

@yantze
Copy link
Member

yantze commented May 11, 2022

在 Windows 上测试 Visual Code 2019 及以上正常,2017 因为一些接口不兼容导致 node-pty 编译原生模块失败。其它的原生模块(nsfw、spdlog)正常。

比如指定 vs2017 进行构建:

VCINSTALLDIR="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild"  "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Administrator\\repo\\ide-electron\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--openssl_fips=X" "--target=18.0.3" "--arch=x64" "--dist-url=https://electronjs.org/headers"

会报错如下:

gyp info find VS using VS2017 (15.9.28307.1974) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
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\\Administrator\\repo\\ide-electron\\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\\Administrator\\repo\\ide-electron\\node_modules\\node-pty\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Administrator\\repo\\ide-electron\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Administrator\\AppData\\Local\\node-gyp\\Cache\\18.0.3\\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\\Administrator\\AppData\\Local\\node-gyp\\Cache\\18.0.3',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\Administrator\\repo\\ide-electron\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\18.0.3\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\Administrator\\repo\\ide-electron\\node_modules\\node-pty',
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\\Administrator\\repo\\ide-electron\\node_modules\\node-pty\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn?[0m C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
?[0m?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn args?[0m [
?[0m?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn args?[0m   'build/binding.sln',
?[0m?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn args?[0m   '/clp:Verbosity=minimal',
?[0m?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn args?[0m   '/nologo',
?[0m?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn args?[0m   '/p:Configuration=Release;Platform=x64'
?[0m?[37;40mgyp?[0m ?[0m?[32minfo?[0m ?[0m?[35mspawn args?[0m ]
?[0mBuilding the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  conpty.cc
c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2061: syntax error: identifier 'TracedGlobal<`template-type-parameter-1'>' [C:\Users\Administrator\repo\ide-electron\node_modules\node-pty\build\conpty.vcxproj]
  c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(335): note: see reference to class template instantiation 'v8::TracedGlobal<T>' being compiled
c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2334: unexpected token(s) preceding ':'; skipping apparent function body [C:\Users\Administrator\repo\ide-electron\node_modules\node-pty\build\conpty.vcxproj]
c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(22): fatal error C1075: '{': no matching token found [C:\Users\Administrator\repo\ide-electron\node_modules\node-pty\build\conpty.vcxproj]
  conpty_console_list.cc
c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2061: syntax error: identifier 'TracedGlobal<`template-type-parameter-1'>' [C:\Users\Administrator\repo\ide-electron\node_modules\node-pty\build\conpty_console_list.vcxproj]
  c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(335): note: see reference to class template instantiation 'v8::TracedGlobal<T>' being compiled
c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(240): error C2334: unexpected token(s) preceding ':'; skipping apparent function body [C:\Users\Administrator\repo\ide-electron\node_modules\node-pty\build\conpty_console_list.vcxproj]
c:\users\administrator\appdata\local\node-gyp\cache\18.0.3\include\node\v8-traced-handle.h(22): fatal error C1075: '{': no matching token found [C:\Users\Administrator\repo\ide-electron\node_modules\node-pty\build\conpty_console_list.vcxproj]
  Agent.cc
  AgentCreateDesktop.cc
  ConsoleFont.cc
  ConsoleInput.cc
  ConsoleInputReencoding.cc
  ConsoleLine.cc

建议使用 Visual Code 2019 及以上的版本,或者直接降级 node-pty 到老版本,也许可行。

@yantze
Copy link
Member

yantze commented May 11, 2022

类似的问题 electron/rebuild#1005

@yantze yantze closed this as completed Jul 6, 2022
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