我在容器中使用的是alpine-linux。不久前,我遇到了与在pkg配置搜索路径中找不到Package cairo相同的错误。Node j.s安装画布问题我在Dockerfile中添加了以下片段:
# Install cairo for one of our frontend dependencies
RUN apk add --update --no-cache cairo
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
这让错误消失了(至少根据我的记忆,已经有几个月了)。
今天,运行docker-compose exec web yarn watch
时再次出现此错误。以下是错误的完整输出:
[4/4] Building fresh packages...
success Installed "node-gyp@3.8.0" with binaries:
[1/2] ⠠ canvas
warning Error running install script for optional dependency: "/var/www/html/node_modules/canvas: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /var/www/html/node_modules/canvas
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.14.0 | linux | x64
gyp http GET https://nodejs.org/download/release/v8.14.0/node-v8.14.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v8.14.0/node-v8.14.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v8.14.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v8.14.0/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/var/www/html/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.node-gyp/8.14.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.node-gyp/8.14.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.node-gyp/8.14.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/var/www/html/node_modules/canvas',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
Package 'cairo', required by 'virtual:world', not found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/share/.config/yarn/global/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.9.125-linuxkit
gyp ERR! command "/usr/bin/node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /var/www/html/node_modules/canvas
gyp ERR! node -v v8.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok"
Done in 98.27s.
我可以证明开罗在集装箱上:
WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such file or directory
cairo-1.14.12-r2 description:
A vector graphics library
cairo-1.14.12-r2 webpage:
http://cairographics.org/
cairo-1.14.12-r2 installed size:
1097728
cairo-1.14.12-r2 depends on:
so:libX11.so.6
so:libXext.so.6
so:libXrender.so.1
so:libc.musl-x86_64.so.1
so:libfontconfig.so.1
so:libfreetype.so.6
so:libpixman-1.so.0
so:libpng16.so.16
so:libxcb-render.so.0
so:libxcb-shm.so.0
so:libxcb.so.1
so:libz.so.1
cairo-1.14.12-r2 provides:
so:libcairo-script-interpreter.so.2=2.11400.12
so:libcairo.so.2=2.11400.12
cairo-1.14.12-r2 is required by:
cairo-1.14.12-r2 contains:
usr/lib/libcairo.so.2.11400.12
usr/lib/libcairo-script-interpreter.so.2
usr/lib/libcairo-script-interpreter.so.2.11400.12
usr/lib/libcairo.so.2
usr/lib/cairo/cairo-sphinx.so.0
usr/lib/cairo/cairo-fdr.so.0
usr/lib/cairo/cairo-fdr.so
usr/lib/cairo/cairo-fdr.so.0.0.0
usr/lib/cairo/cairo-sphinx.so
usr/lib/cairo/cairo-sphinx.so.0.0.0
cairo-1.14.12-r2 triggers:
cairo-1.14.12-r2 has auto-install rule:
cairo-1.14.12-r2 affects auto-installation of:
cairo-1.14.12-r2 replaces:
cairo-1.14.12-r2 license:
LGPL-2.0-or-later MPL-1.1
经过一些浏览,我在任何地方都看不到任何cairo.pc
文件,所以我如何确定需要采取什么步骤来教育我的yarn install
cairo的位置?
这可以通过安装cairo-dev
包轻松修复。
根据Alpine的软件包搜索,它将在/usr/lib/pkgconfig
下安装cairo.pc
,这很可能被gyp
:检测到
https://pkgs.alpinelinux.org/contents?file=cairo.pc&路径=&name=&分支=v3.8