【问题标题】:Gulp issues with cario install command not found when trying to installing canvas尝试安装画布时找不到 cario install 命令的 Gulp 问题
【发布时间】:2014-04-09 05:06:39
【问题描述】:

我对在命令行中工作还很陌生。我有一个正在使用 gulp 设置的项目,并且安装了 gulp 并成功编译了 sass 文件。但是,我无法通过以下方式安装画布:

$ npm install canvas

我需要安装画布,因为 css-sprite 必须运行依赖项。我收到以下错误。我已经安装了 cairo、quartz 和 homebrew。我研究了其他票证并尝试运行export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig 并再次安装。我没有运气,也不知道在尝试排除故障时还能做什么。

这是错误...

npm http GET https://registry.npmjs.org/canvas
npm http 304 https://registry.npmjs.org/canvas
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan

canvas@1.1.3 install /usr/local/lib/node_modules/canvas
node-gyp rebuild

./util/has_cairo_freetype.sh: line 4: pkg-config: command not found
gyp: Call to './util/has_cairo_freetype.sh' returned exit status 0.
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Darwin 13.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/canvas
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm ERR! canvas@1.1.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the canvas@1.1.3 install script.
npm ERR! This is most likely a problem with the canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls canvas
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "canvas"
npm ERR! cwd /Users/kylebebeau/websites/ls/code/templates/ls3
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/kylebebeau/websites/ls/code/templates/ls3/npm-debug.log
npm ERR! not ok code 0

任何帮助或指导将不胜感激。

【问题讨论】:

    标签: canvas npm cairo gulp


    【解决方案1】:

    我也有这个问题。我还使用 brew 来安装 cairo 和quartz。我遵循了这些说明here,最具体地说,这一步解决了我的问题。

    export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

    如果您希望它在会话中持续存在,请确保将其添加到您的 .bashrc.zshrc。我在成功编译后删除了我的node_modules 目录,并在新的终端会话中再次尝试npm install,我不得不重新导出该PKG_CONFIG_PATH 以使其再次正确编译。

    这是我的输出缩写来演示。

    $ npm install
    > node-gyp rebuild
    Package xcb-shm was not found in the pkg-config search path.
    Perhaps you should add the directory containing `xcb-shm.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'xcb-shm', required by 'cairo', not found
    gyp: Call to './util/has_cairo_freetype.sh' returned exit status 0. while trying to load binding.gyp
    gyp ERR! configure error
    ...
    
    $ export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig
    $ npm install                            
    
    $ canvas@1.1.3 install $HOME/projects/canvas/node_modules/canvas
    $ node-gyp rebuild
    ...
    Successful Compile
    

    npm start 此时工作没有错误

    我希望这对遇到此问题的其他人有所帮助。

    【讨论】:

    • 如果您需要 PKG_CONFIG_PATH 用于 X11 以及其他包,您可以执行以下操作:“export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:/usr/local/bin/pkg-config”或这不可能?
    猜你喜欢
    • 2014-04-09
    • 1970-01-01
    • 2020-01-08
    • 1970-01-01
    • 2014-09-25
    • 2014-07-24
    • 1970-01-01
    • 2013-10-29
    • 2019-06-26
    相关资源
    最近更新 更多