我有一个电子应用程序,当前使用 elecron forge 运行。 每当我尝试使用命令启动项目时就会出现此问题
npm run start
如果我对画布有依赖,它将无法工作。我知道画布具有本机模块依赖性。如果我尝试启动应用程序,它总是这样说
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)
只有当我删除我网站上的画布功能并卸载它时,它才能成功重建。我使用的是nodejs 18.20.3、电子33.0.1和电子锻造7.5.0 有谁知道如何解决这个问题吗?
最后,我删除了对画布的依赖。 并且它不再需要本机模块...之前我使用画布在我的网站上显示一些图表。
但我替换了名为
的库图表
之后它就不再需要画布了 谢谢