node.jselectronnode-gypelectron-forge

Failed to rebuild and start electron app using nodejs v18.20.3


i've electron app that currently running using elecron forge. the issue is appear whenever i tried to start the project using command

npm run start

It will not working, if i have dependencies on canvas. i know canvas have native modules dependencies. it always said like this if i tried to start the app

Done Building Project "C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\binding.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\binding.sln" (default target) (1) ->
"C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas-postbuild.vcxproj.metaproj" (default target) (2) ->
"C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas.vcxproj" (default target) (3) ->
(ClCompile target) ->
  C:\Users\rikim\.electron-gyp\33.0.2\include\node\v8-primitive.h(616,62): warning C4324: 'v8::String::ValueView': structure was padded due to alignment specifier [C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas.vcxproj]


"C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\binding.sln" (default target) (1) ->
"C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas-postbuild.vcxproj.metaproj" (default target) (2) ->
"C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas.vcxproj" (default target) (3) ->
(ClCompile target) ->
  C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\nan\nan_scriptorigin.h(36,23): error C2665: 'v8::ScriptOrigin::ScriptOrigin': no overloaded function could convert all the argument types [C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas.vcxproj]
  C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\nan\nan_scriptorigin.h(40,23): error C2665: 'v8::ScriptOrigin::ScriptOrigin': no overloaded function could convert all the argument types [C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas.vcxproj]
  C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\nan\nan_scriptorigin.h(47,23): error C2665: 'v8::ScriptOrigin::ScriptOrigin': no overloaded function could convert all the argument types [C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas\build\canvas.vcxproj]

    1 Warning(s)
    3 Error(s)

Time Elapsed 00:00:02.61
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
    at ChildProcess.<anonymous> (C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\@electron\node-gyp\lib\build.js:215:23)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

× Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild 'C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas'

Error: node-gyp failed to rebuild 'C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\canvas'
    at ChildProcess.<anonymous> (C:\Users\rikim\Documents\appangular\oneapp-ui\node_modules\@electron\rebuild\lib\module-type\node-gyp\node-gyp.js:121:24)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

Only when i delete the canvas feature on mywebsite and uninstall it, then it manage to rebuild. I'm using nodejs 18.20.3, electron 33.0.1, and electron forge 7.5.0 Anyone know how to solved this ?


Solution

  • At the end, i removed my dependencies to canvas. and it doesn't required native modules anymore ... previously i'm using canvas to show some chart on my websites.

    but i replace the library called

    echarts

    and it doesn't really need canvas again after that thanks