gpt4 book ai didi

linux - 在 Amazon Linux 上安装 node-postgres 时出错。缺少 pg_config.h 文件

转载 作者:IT王子 更新时间:2023-10-29 00:49:31 25 4
gpt4 key购买 nike

这个错误在 Windows 机器上似乎很常见,但是当我 npm install pg 时,我的 Amazon Linux EC2 实例抛出了这个错误:

../src/binding.cc:1:23: fatal error: pg_config.h: No such file or directory
#include <pg_config.h>
^
compilation terminated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
make: Leaving directory `/home/ec2-user/macros/test/stateHash/node_modules/pg/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Linux 3.4.82-69.112.amzn1.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ec2-user/macros/test/stateHash/node_modules/pg
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.10.6
gyp ERR! not ok

我在 Amazon Linux 2014.03 上,它是一个运行 node 0.10.28 的微型实例。

Postgres 9.2.7 从 Amazon 存储库安装。具体来说,postgresql9* 包。

在新的 updatedb 上,locate pg_config 返回

/usr/bin/pg_config
/usr/share/locale/cs/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/de/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/es/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/fr/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/it/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/ja/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/ko/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/nb/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/pl/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/pt_BR/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/ro/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/ru/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/sv/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/ta/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/tr/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/zh_CN/LC_MESSAGES/pg_config-9.2.mo
/usr/share/locale/zh_TW/LC_MESSAGES/pg_config-9.2.mo
/usr/share/man/man1/pg_config.1.gz

但是 locate pg_config.h 什么都不返回。

有什么想法吗?

最佳答案

默认安装了postgresql9postgresql9-libspostgresql9-server,但没有安装postgresql9-devel.

node-postgres 所需的头文件在缺少的开发包中。以下步骤解决了我的问题:

  1. 删除 node-postgres 目录:

    $ rm -rf node_modules/pg

  2. 从存储库安装 postgres 开发包(仔细匹配您的版本 - 涉及 postgres 时亚马逊存储库一团糟):

    $ sudo yum install postgresql9-devel

  3. 重新安装 node-postgres(我在本地安装,您可能正在使用 -g 选项):

    $ npm install pg

pg_config.h 文件应该在那里,所以安装应该可以正常进行!

关于linux - 在 Amazon Linux 上安装 node-postgres 时出错。缺少 pg_config.h 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24422209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com