【问题标题】:gyp Failing when Installing pg-native安装 pg-native 时 gyp 失败
【发布时间】:2015-10-05 12:42:44
【问题描述】:

我正在尝试安装 pg-native 包:

sudo npm install pg-native

但是会产生以下错误:

> libpq@1.7.0 install /Workspace/auth/node_modules/libpq
> node-gyp rebuild

/bin/sh: pg_config: command not found
gyp: Call to 'pg_config --libdir' returned exit status 127. 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/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:355:16)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "/usr/local/Cellar/node/4.1.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Workspace/auth/node_modules/libpq
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
npm WARN install:libpq libpq@1.7.0 install: `node-gyp rebuild`
npm WARN install:libpq Exit status 1

我尝试通过安装 node-gyp 模块然后手动运行重建命令来解决这个问题:

sudo npm install -g node-gyp
sudo node-gyp rebuild

我了解到这个问题在最新版本的 Node 中不再存在,所以我更新到版本 v4.1.1

我还尝试将模块本地安装到工作区和全局安装到机器的其余部分,但仍然没有运气。运行node-gyp 可以正常工作,所以看起来已经正确安装了。

对于这个问题的任何帮助将不胜感激!

【问题讨论】:

    标签: node.js macos libpq gyp


    【解决方案1】:

    不知道为什么我最初没有想到这个,但是installing libpq on my local machine解决了这个问题。

    brew install postgresql
    

    这个捆绑包附带libpq,考虑到错误消息的模糊性,我一开始并没有意识到需要它。

    看起来它要么已安装,要么作为先决条件安装,因为错误消息中的第一行标识了此软件包的版本号 libpq@1.7.0

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-19
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2016-02-27
    • 1970-01-01
    • 2021-04-02
    相关资源
    最近更新 更多