Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.17k stars 1.17k forks source link

Support bun runtime #2302

Open cwtuan opened 1 year ago

cwtuan commented 1 year ago

Feature

Support bun runtime

Steps to Reproduce

Run the example in bun runtime caused error:

 dlopen(/xxxx/node_modules/canvas/build/Release/canvas.node, 0x0001): tried: '/Users/tony/workspace/github/cwtuan/fe-tool/node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
      at internalRequire (:1:20)
      at /xxxx/node_modules/canvas/lib/bindings.js:3:6
      at globalThis (/xxxx/node_modules/canvas/lib/bindings.js:12:8)
      at overridableRequire (:1:20)
      at /xxxx/node_modules/canvas/lib/canvas.js:9:6
      at globalThis (/xxxx/node_modules/canvas/lib/canvas.js:111:77)
      at overridableRequire (:1:20)

Your Environment

7f8ddd commented 10 months ago

It builds and works fine on Bun, the maintainers just haven't released a version since they migrated to NAPI. If you use the .git link in "bun i git+githere" then it'll successfully build it and work, given you have the dependencies.

But it does seem that there is a bug in Bun currently causing it to crash after repeated calls.

ColormaticStudios commented 8 months ago

When I try to run my project with Bun, I get the error

node_modules/canvas/build/Release/canvas.node: undefined symbol: node_module_register

I am using https://github.com/akira-cn/node-canvas-webgl, but this seems to be a problem with node-canvas.

EDIT: works fine with Node

chuckstock commented 4 months ago

+1