-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Unable to find module canvas
#4259
Comments
With node/npm I often see something like this as well, and in that case the solution is to rebuild the library. This section of MapLibre GL JS contribution guidelines explains it well:
So if you go to node_modules/canvas and run ➜ bun run index.ts
dyld[67546]: missing symbol called
zsh: killed bun run index.ts Debug log[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1860)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1978)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1890)
[ModuleLoader] transpileFile: /Users/admin/repos/canvas-test/node_modules/canvas/index.js
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[fs] openat(0, /Users/admin/repos/canvas-test/node_modules/canvas/index.js) = 5
[fs] stat(5) = 2933
[fs] pread(5, 2933) = 2933
[fs] readdir(7, /Users/admin/repos/canvas-test/node_modules/canvas/lib/) = 10
[fs] open(/Users/admin/repos/canvas-test/node_modules/canvas/lib) = fs.IterableDir{ .dir = fs.Dir{ .fd = 7 } }
[SYS] close(7)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1860)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1978)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1890)
[ModuleLoader] transpileFile: /Users/admin/repos/canvas-test/node_modules/canvas/lib/canvas.js
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[fs] openat(0, /Users/admin/repos/canvas-test/node_modules/canvas/lib/canvas.js) = 5
[fs] stat(5) = 3264
[fs] pread(5, 3264) = 3264
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] toJS (src/string.zig:501)
[JSC] Bun__fetchBuiltinModule (src/bun.js/module_loader.zig:1860)
[JSC] Bun__runVirtualModule (src/bun.js/module_loader.zig:1978)
[CPP] JSGlobalObject__bunVM
[CPP] JSGlobalObject__bunVM
[JSC] Bun__transpileFile (src/bun.js/module_loader.zig:1890)
[ModuleLoader] transpileFile: /Users/admin/repos/canvas-test/node_modules/canvas/lib/bindings.js
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[fs] openat(0, /Users/admin/repos/canvas-test/node_modules/canvas/lib/bindings.js) = 5
[fs] stat(5) = 280
[fs] pread(5, 280) = 280
[fs] readdir(7, /Users/admin/repos/canvas-test/node_modules/canvas/build/Release/) = 4
[fs] open(/Users/admin/repos/canvas-test/node_modules/canvas/build/) = fs.IterableDir{ .dir = fs.Dir{ .fd = 7 } }
[fs] readdir(7, /Users/admin/repos/canvas-test/node_modules/canvas/build/) = 8
[fs] open(/Users/admin/repos/canvas-test/node_modules/canvas/build/Release) = fs.IterableDir{ .dir = fs.Dir{ .fd = 8 } }
[SYS] close(7)
[SYS] close(8)
[JSC] createLatin1 (src/string.zig:328)
[SYS] close(5)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] fromJS (src/string.zig:479)
[JSC] fromJS (src/string.zig:479)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] ref (src/string.zig:107)
[JSC] ascii (src/bun.js/bindings/bun-simdutf.zig:105)
[JSC] deref (src/string.zig:95)
[JSC] deref (src/string.zig:95)
[JSC] toJS (src/string.zig:501)
dyld[71930]: missing symbol called
zsh: killed BUN_DEBUG_ALL=1 BUN_JSC_dumpModuleLoadingState=1 --bun run index.ts |
edit: it relies on V8 so it won't work but by 1.0 it should be solved |
Is this what you're talking about https://bun.sh/docs/runtime/nodejs-apis#node-v8 |
yes, v8 is engine but bun is running on WebKit so we must do polyfill |
alright, thanks! |
Automattic/node-canvas#2235 This will fix canvas whenever it gets pushed, which should be pretty soon. |
Looks like with Automattic/node-canvas#2235 merged, I am still encountering the same error. ❯ bun add canvas@Automattic/node-canvas
[0.81ms] ".env.local"
bun add v1.0.0 (822a00c4)
installed canvas@github:Automattic/node-canvas#16c28ab
1 packages installed [1.90s] "dependencies": {
"canvas": "Automattic/node-canvas",
"css": "^3.0.0",
"elysia": "latest"
}, ❯ bun dev
$ bun run --watch src/index.ts
[0.08ms] ".env.local"
error: Cannot find module "../build/Release/canvas.node" from "[dir]/node_modules/canvas/lib/bindings.js" Would maybe using an alternative package such as @napi-rs/canvas or sharp work? EDIT: Using @napi-rs/canvas is a great alternative. Basically the same thing. |
Workaround: However, this leads me to #4290 |
Closing as a duplicate of #5835 |
What version of Bun is running?
0.7.3
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
In a new project
bun init
bun add konva canvas
I'm thinking this has to do something with canvas not being installed properly?
What is the expected behavior?
Being able to log the
dataURI
succesfullyWhat do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: