Comments (6)
I was hitting this on my M2 mac and noticed it was trying to compile the binary for 2 reasons:
- I was using Node 21, which was generating an assumed pre-built binary path including
...node-v120...
while the latest canvas v2.11.2 release indicates it's the first release using Node v20. There are no binary paths for the release withnode-v120
in them.- If I use Node v20.11.1, then the generated download path includes
node-v115
which is a match.
- If I use Node v20.11.1, then the generated download path includes
- I was using my M2 mac, resulting in a download path ending in
...arm64.tar.gz
(ARM x64) while all paths end in...x64.tar.gz
(Intel x64).
Because the download was failing for both reasons (I presume it would fail on an Intel mac running Node v21 as well because of (1)), npm was now wanting to compile a new binary.
The compilation would then fail because of a missing pixman-1
package. I installed that and then it failed on missing cairo
.
Thankfully, I checked out the README and found that there are a bunch of compilation instructions (thank you -- would be great to mention this in the Release docs too, right after the Node version info...) for various platforms suggesting to run this on Mx macs:
$ brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
During the install of cairo
, I noticed Brew installed [email protected]
as a dependency. So once the installation of all packages was finished, I used pyenv
to set my active Python version to 3.12.1
and then ran:
$ npm install canvas # SUCCESS 🎉
Hope this helps...
from node-canvas.
@coderfin Thank you! Will check that out
from node-canvas.
I can confirm this, using Node 21 seems to be impossible at the moment as @stefcameron mentioned. Following the build instructions from the README I never really had problems building the canvas module on an MacBook Air with M1 for a long time until I switched to Node 21. Falling back to Node 20 the installation works. Maybe it's worth mentioning this also in the README.
from node-canvas.
@coderfin goooosh, thanks a lot of that, man
I've been bumping into different random issues with fonts for 2 days straight, switched to alternative and it JUST WORKS WOW
OMG lifesaver
from node-canvas.
I'm not associated with this project or https://github.com/Brooooooklyn/canvas but I found that https://www.npmjs.com/package/@napi-rs/canvas is a great replacement for node-canvas. @napi-rs/canvas
supports Intel and Arm (M Chip) Macs with no system dependencies. It supports all the same features that I needed. It also supports webp
which was a welcome bonus and is MIT license.
Instead of registerFont
use GlobalFonts.registerFromPath
; createCanvas
and loadImage
remain the same.
from node-canvas.
you can build canvas from source, you will need python3/python3-dev packages + install requirements for canvas. if all required things are found, node-gyp should build canvas from source
from node-canvas.
Related Issues (20)
- Failed to use registered font with SvelteKit app on Node server HOT 1
- 'drawImage()', then '.toBuffer('application/pdf')', but the image is fuzzy HOT 1
- The loadImage() method can fail with Request timed out error on older hardware HOT 2
- Mark TextMetrics#fontBoundingBoxAscent etc. as unimplemented HOT 1
- Cannot install canvas on apple silicon HOT 13
- SVG cannot load the image link & font CSS HOT 1
- Move away from GTK 2 to newer libraries on Windows HOT 1
- Unexpected font fallback strategy on Linux
- npm intall not working HOT 9
- mac OS 14 => Cant install despite all other issues and installation guide HOT 6
- Canvas installation failure with Node v20.12.1 HOT 2
- Running electron-builder on Win11 fails when package "pdfjs-dist" is included because of ~/node_modules/canvas HOT 3
- How to use prebuild for AWS lambda? HOT 1
- npm intall not working on node v22 HOT 9
- node-canvas will not install. at all. HOT 6
- loadImage function is not allowing use of await keyword HOT 1
- Canvas fails to import after install HOT 2
- installation error due to the dependency of node-pre-gyp ERR i've spend 1 day's solving this HOT 3
- Calling `registerFont()` on multiple fonts in same family appears to break prior registration (Avenir Next Rounded)
- 'colorSpace' missing from the declaration of ImageData
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-canvas.