NodeJS 无法在npm上安装画布

8xiog9wr  于 2022-11-29  发布在  Node.js
关注(0)|答案(2)|浏览(312)

我试图通过npm在我的树莓派上安装画布成功安装在我的主电脑后,但现在我得到了一个很长的错误,我不知道如何修复。
以下是完整的错误:

npm ERR! gyp info spawn args ]
npm ERR! Package pixman-1 was not found in the pkg-config search path.
npm ERR! Perhaps you should add the directory containing `pixman-1.pc'
npm ERR! to the PKG_CONFIG_PATH environment variable
npm ERR! No package 'pixman-1' found
npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.15.32+
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/home/alex/discord-bot/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/home/alex/discord-bot/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /home/alex/discord-bot/node_modules/canvas
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/home/alex/discord-bot/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/alex/discord-bot/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/alex/discord-bot/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Linux 5.15.32+
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/home/alex/discord-bot/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
npm ERR! node-pre-gyp ERR! cwd /home/alex/discord-bot/node_modules/canvas
npm ERR! node-pre-gyp ERR! node -v v16.16.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.9
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alex/.npm/_logs/2022-08-09T20_08_23_632Z-debug-0.log

我使用了命令npm install --build-from-source canvas,请问我能得到帮助吗?

cbjzeqam

cbjzeqam1#

看起来你缺少了“pixman”依赖项。在安装canvas之前,你是否按照guide安装了所有需要的依赖项?它需要一堆dependencies

pvabu6sv

pvabu6sv2#

在运行npm安装canvas之前试试这个。它对我很有效
brew安装软件包配置开罗pango libpng jpeg giflib librsvg
参考:https://flaviocopes.com/fix-node-canvas-error-pre-gyp-macos/

相关问题