-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
precompiled packages targeting electron are not available #1467
Comments
Is there any easy way to include node-canvas with Electron, without having to figure out rebuilding the node-canvas package and relocating the dynamic libraries ? Could you perhaps provide a version prebuilt for Electron ? |
I also encountered this problem, but, by directly under ... \ node_modules \ canvas,
|
Well I got the package working on macOS at least, what I did was install the official canvas prebuilt npm package, not built for electron, copied all the libraries include within it (under the installed package there is a group of prebuilt library binaries included, ligjpeg etc), copied all those to a separate temporary directory. Then I rebuild the node-canvas module manually against local development libraries installed with macports, with node-gyp inside the electron node_modules directory. After this, I copied the previously copied library binaries inside the re-build node-canvas, and wrote this script to relocate the libraries from /opt/local/lib to the location inside the node_modules/canvas directory.
So you can maybe adapt this to your use, this works on macOS only though, have to figure out what the required tools are in windows to relocate the library locations. |
Interestting. the dylibs that ship with the prebuilts are all setup to link against @loader_path and against existing system binaries only? I tried to do what you did, but i got something saying one of the libraires was too old:
|
No, not the system libraries. But the libraries provided with the canvas prebuilt package, that is where the @loader_path is referring to. But you should be able to compile Electron compatible versions of those libraries and relocate inside your own project, then change the library reference paths with the above command.
Yeah don't know what versions you are compiling with. I'm using Macports and the canvas rebuilt fine against those. |
I tried to get all the lastest versions but inside all dylibs there is other links to /opt/local/lib ...
|
Hey finally found a good solution for fixing this build, at least on macOS. Anyway, this is how I did it:
Key point is here fixing the .dylib dependencies. You can do it with this macdylibbundler tool listed above.
This needs to be run inside the node_modules/canvas/build/Release directory after building the module with electron-rebuild. This will find out all the library dependencies and fix the paths in them also, resulting in a bunch of library files on your build/Release directory. For me, with SVG support builtin, this comes to a total whopping of about 70 megabytes of libraries .. Anyway, hope this helps you out there! Maybe this tool can be ported to Linux also if needed, not sure. |
Also here is a tool you can view library dependencies in recursive manner in macOS, to help fixing these and confirming: https://github.com/kwin/macdependency |
I have developed and tested a package using node-canvas. Everything worked fine. Now I am trying to use my package in another project that is targetting electron environment. Here the download of the canvas package fails because pre-built packages targeting that environmet are not available.
Issue or Feature
Need support for pre-built binaries for electron.
Steps to Reproduce
Use the Canvas package from package.json dependencies section on a project that targets electron environment.
error:
error D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | x64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas\build\Release\canvas.node" (not found)
node-pre-gyp http GET https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-electron-v4.2-win32-unknown-x64.tar.gz
node-pre-gyp http 404 https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-electron-v4.2-win32-unknown-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-electron-v4.2-win32-unknown-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (electron-v4.2 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-electron-v4.2-win32-unknown-x64.tar.
gz
D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....
\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node "" clean )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info ok
D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....
\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas\build\Release\canvas.node -
-module_name=canvas --module_path=D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas\build\Release --napi_version=3 --node_abi_napi=napi --napi_build_version
=0 --node_napi_label=electron-v4.2 ) else (node "" configure --fallback-to-build --module=D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas\build\Release\c
anvas.node --module_name=canvas --module_path=D:\src\azuredatastudio\extensions\integration-tests\node_modules\canvas\build\Release --napi_version=3 --node_abi_napi=napi --napi_b
uild_version=0 --node_napi_label=electron-v4.2 )
Your Environment
Version of node-canvas (output of
npm list canvas
oryarn list canvas
):$ npm list canvas
[email protected] D:\src\adstest
-- [email protected]
-- [email protected]Environment (e.g. node 4.2.0 on Mac OS X 10.8):
$ node -v
v10.15.3
Windows Version 1903 (OS build 18362.239)
The text was updated successfully, but these errors were encountered: