【问题标题】:Canvas module compilation osx error画布模块编译osx错误
【发布时间】:2013-11-08 13:30:44
【问题描述】:

我正在尝试安装验证码 npm 模块,该模块利用了 canvas 模块。

不幸的是,我在 OSX 上安装该模块时遇到问题。 我收到以下错误:

> canvas@1.0.4 install ....../node_modules/canvas
> node-gyp rebuild

not found: ldconfig
gyp: Call to './util/has_lib.sh jpeg' returned exit status 0. 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/Cellar/node/0.10.21/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:424:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/Cellar/node/0.10.21/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd ...../node_modules/canvas
gyp ERR! node -v v0.10.21
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm ERR! weird error 1

有什么想法吗?显然缺少 ldconfig 。但是不知道怎么安装。

我正在使用自制软件,并且安装了最新的 XCode 和命令行工具。

【问题讨论】:

    标签: macos node.js canvas npm homebrew


    【解决方案1】:

    M1 native 在node15 中没有发布canvas 的二进制版本。所以安装canvas的时候会自动从源码编译,但是如果不安装对应的依赖就会报错。

    解决方案

    arch -arm64 brew install pkg-config cairo pango jpeg giflib librsvg

    【讨论】:

      【解决方案2】:

      据我所知,您需要安装 Get Xcode 6.1 。

      安装 Xcode 和 Xcode 命令行工具

      同意终端中的 Xcode 许可:sudo xcodebuild -license

      为您的 OS X 版本安装 MacPorts: OS X 10.10 优胜美地

      https://www.macports.org/install.php

      【讨论】:

        【解决方案3】:

        这是我的解决方法:

        首先我们需要安装 cairo:

        brew install cairo jpeg
        

        这需要一些时间。但是现在是时候更新 PKG_CONFIG_PATH,指向 cairo 库了。

        export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
        

        要编译画布,我们需要安装 node-gyp。

        npm install node-gyp -g
        

        如果由于缺少jpeg lib而导致安装仍然无法正常运行,则需要运行:

        npm install canvas
        

        在需要它的项目目录中,然后在错误报告之前停止安装。然后您需要更改目录并手动重新编译 C++ 绑定

        cd node_modules/canvas/
        node-gyp rebuild
        

        之后你应该有工作画布模块。

        【讨论】:

          猜你喜欢
          • 2016-05-29
          • 1970-01-01
          • 2012-11-19
          • 1970-01-01
          • 2018-02-16
          • 1970-01-01
          • 2021-08-29
          • 2012-11-21
          • 1970-01-01
          相关资源
          最近更新 更多