-
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
Can't install on Apple M1 #1733
Comments
I also didn't get it to work so far! If you manage to find a solution, I'd be very happy if you told me how 😊 |
Ok, I somehow got it to work but I really don't know what I changed... I assume you ran Also be sure you ran I hope this helps you somehow, but as I said I really have no idea why suddenly everything works |
Could be a little bit off topic, for me it seems that the /opt/homebrew/include folder is not in clang include path. If you see this error: To summarize, the following works for me, |
This is what i got after trying the above
|
I'd suggest you try double checking cairo installation, as you see you got Please do something like Once you found it, add it to CPLUS_INCLUDE_PATH and see what happen. |
When i reinstall everything with brew, this is the output. So it seems like everything gets installed in usr/local/Cellar
running Is it getting installed into the wrong location? I'm still getting the same error as above, cairo.h not found. I ran Any suggestions? |
CPLUS_INCLUDE_PATH should be set to a folder not a file. Please google it for more details. Also there should be a symbolic link to /opt/homebrew/include. You don't need to point to that directory actually assuming brew (itself) installation is intact. |
Okey i see, what path should i set for CPLUS_INCLUDE_PATH? i tried usr/local/ but didnt work |
Ideally For now you can try |
any recommendations how to fix brew? i suspect fish shell to be breaking everything |
@Glutch It looks a bit like you installed homebrew under rosetta? See https://docs.brew.sh/Installation, for intel it installs in /usr/local and for apple silicon to /opt/homebrew. |
I'm really trying but i can't figure this out. I've created a rosetta 2 terminal shortcut and tried reinstalled brew there, and with removed node_modules etc but i'm still getting the missing cairo.h error message can someone write step by step including commands to run? |
Are you using
Also you could be mixing both Also nuke your |
add $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 12.4.0.0.1.1610135815
volume: /
location: /
install-time: 1612200617
groups: com.apple.FindSystemFiles.pkg-group |
Hello, there. I sovled this in my mac big sur(11.1), there is my steps:
The reasion is that Apple M1 is based on arm, then can't find |
This worked for me:-
And then npm i canvas |
Hi @Glutch , Did you resolve the problem? and How did you fix it ? I got the same your problem but I cannot fix on Mac M1 |
This saved my day... Thank you |
Thank you. That's worked for me! |
arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg this works perfect but now i have problems using jest commands. has anyone face something like this error ?
|
Made this and worked here |
did you figure out how to fix this? I tried these in different orders, but could not fix the arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg
CPLUS_INCLUDE_PATH=/usr/local/include npm i canvas |
I did actually. the problem was NVM or node it self. what i did was uninstall NVM completely following this: and then installed it following this article: good luck |
I tried this and worked flawlessly but I got incompatibility with other things, there's any way to reverse this installation? because there are other libs using those as dependency and I don't wanna break everything |
worked for me. |
We are getting this when build the docker image. Do it needs more work to be done for docker build? |
I ran into a form of this issue, with variation- # this allowed me to take my existing v12.22 node_modules from my x86 and run successfully on my m1
# in ventura with the M1, homebrew will be installed, and install everything, in /opt/homebrew
# if you try to `arch=x86_64 brew install <....>`, brew will build, then error, saying
# that it can't install any x86_64 in /opt/homebrew, you need to install them in /usr/local
# SO! we are going to add *a second, separate brew* installed in /usr/local for x86 builds
# This will allow us to build & install the x86_64 toolchain that the existing x86 node-canvas (installed in node_modules) will use
# install:
# copy your existing x86 node v12 node_modules to your new machine (*do NOT run npm install from a fresh clone on the m1)
cd /usr/local
sudo mkdir homebrew
sudo chown $(whoami):admin homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
cd homebrew/bin
# this will take a long time, it builds a ton from source
arch -x86_64 ./brew install pixman pkg-config cairo pango libpng jpeg giflib librsvg
# running before adding this link threw an error that pixman could not be found (did not have it installed in arm64)
ln -sf /usr/local/homebrew/Cellar/pixman/0.42.2/lib/libpixman-1.0.dylib /usr/local/opt/pixman/lib/libpixman-1.0.dylib
# adding the above link caused node to look for all the other node-canvas dependencies in /usr/local/opt/
# so now we'll link /usr/local/opt to /usr/local/homebrew/opt
cd /usr/local
sudo ln -sf homebrew/opt/ opt
chown $(whoami):admin opt Hope this helps someone - I realized that despite the same error, we're all trying to solve different variations of the problem depending if your project's node version is before or after 16 (arm64 support) |
Ran into the same issue. Nothing from here was able to fix it. Eventually I reinstalled the brew packages by building from source and that fixed it!
I still don't know why... I suspect something with my homebrew installation is messed up. |
Nothing helped me, I stuck with the following:
The issue with this part of the code:
Use m1 pro, volta (try node 16.18.1, 18.16.0), use esbuild with options "--platform=node --loader:.node=file" In my attempts perform these commands:
According to this comment all staff for arm64: (volta, node, canvas) |
I also had a similar issue, but instead ran the following with success:
|
This worked for me... just dont forget to uninstall canvas then re install. |
This fixes an issue when a contributor runs `npm install` using Apple Silicon which would fail since there is no precompiled arm64 binary to download for `canvas`. The error looks like this: ``` npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-darwin-unknown-arm64.tar.gz npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-darwin-unknown-arm64.tar.gz npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@18.19.0 (node-v108 ABI, unknown) (falling back to source compile with node-gyp) ``` Since we don't have a [special case](https://github.com/vercel/nft/blob/main/src/utils/special-cases.ts) for `canvas` and it never worked with Vercel deployments, we can remove the test. It also doesn't decrease code coverage (in fact, I bumped code coverage thresholds just to be sure). ### Related - Automattic/node-canvas#1733 - vercel/vercel#3460
I ran into a similar issue w/ a slightly different error message (errored on
Ran into a bunch of warnings about stuff not being linked in my output, and then I found this stackoverflow which made me check my macOS latest, m3 max, node 16.14.0 |
For all those struggling with manually building the package on a Mac, besides With |
Does anyone have problems with getting it to work in a CD/CI environment? I'm attempting to deploy node-canvas within firebase functions, and I get the above errors, even though it works fine locally.
|
It's really amazing. I always get 404 when using npm, but yarn succeeds. After deleting the lock file and npm_module, I used the command |
I got
And this command works for me:
|
Issue or Feature
Steps to Reproduce
Not sure. I've installed Xcode tools, updated system to 11.1. Build from source with brew, port, reinstalled multiple times, reinstalled node-gyp, built from source, read 100 different threads, tried 100 different options. I'm so deep into this hole i have no idea what i've done. Please help me.
Your Environment
├── canvas@2.6.1
├─┬ editly@0.11.1
│ ├── canvas@2.6.1 deduped
│ └─┬ fabric@4.3.0
│ └── canvas@2.6.1 deduped
├─┬ text-to-image@2.4.4
│ └── canvas@2.6.1 deduped
└─┬ text2png@2.3.0
└── canvas@2.6.1 deduped
node v15.4.0
OSX 11.1 Big Sur - Apple Silicon M1
The text was updated successfully, but these errors were encountered: