簡體   English   中英

運行項目時節點 Canvas 拋出錯誤

[英]Node Canvas throwing error when running project

節點 Canvas 在 m1 上不適合我

當我嘗試運行我的項目時,我收到以下錯誤消息:

Error: dlopen(.../node_modules/canvas/build/Release/canvas.node, 0x0001): tried: '.../node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/canvas.node' (no such file), '/usr/lib/canvas.node' (no such file)

已經做了:

brew install pkg-config cairo pango libpng jpeg giflib librsvg

xcode-select --install

npm i canvas

沒有錯誤

不確定如何調試此問題,因為有人使用 Node Canvas 在 m1 筆記本電腦上工作,請幫忙。

最重要的是確保您的 Node 可執行文件已針對 Apple Silicon 編譯,這意味着darwin-arm64有一個預構建的二進制文件。 您可以在此處查看哪些版本具有哪些二進制文件(以下頁面包含 Node 版本 16.13.1 的二進制文件): https://nodejs.org/download/release/v16.13.1/

Node v14 沒有用於darwin-arm64的預構建二進制文件(請參閱https://github.com/nodejs/node/issues/36161 ),因為它不能本地編譯到 Apple Silicon。

I use volta ( https://volta.sh/ ) to manage my Node versions, so if you install Node v16 with volta install node@16 and then run npm i canvas , you should get a correctly compiled canvas.node file.

If that fails, go to node_modules/canvas and run npm install --build-from-source , which will compile the C++ addon and output the corect canvas.node .

您可以通過運行檢查這一點:

file node_modules/canvas/build/Release/canvas.node
# outputs: node_modules/canvas/build/Release/canvas.node: Mach-O 64-bit bundle arm64

如果它最后說arm64 ,那么你對 go 很好。 如果它仍然顯示x86_64 ,那么就出了問題。

我使用npm install --build-from-source 這行得通!

但是有新的錯誤

dlopen(.../node_modules/canvas/build/Release/canvas.node,0x0001):在平面命名空間“_cairo_fill”中找不到符號

npm install --build-from-source之后我遇到了一個新問題

dlopen(.../node_modules/canvas/build/Release/canvas.node,0x0001):在平面命名空間“_cairo_fill”中找不到符號

有人修過這個嗎?

有什么解決方案嗎?

dlopen(.../node_modules/canvas/build/Release/canvas.node,0x0001):在平面命名空間“_cairo_fill”中找不到符號

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM