2014-06-26 63 views
6

这个错误似乎是常见的Windows盒,但我的Linux亚马逊EC2实例抛出这个错误,当我npm install pg在Amazon Linux上安装node-postgres时出错。缺少pg_config.h文件

../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 

我在亚马逊的Linux 2014.03,这是一个微运行实例节点0.10.28

Postgres 9.2.7从Amazon回购站安装。具体来说就是postgresql9*包。

在新鲜updatedblocate 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回报什么。

任何想法?

回答

7

postgresql9,postgresql9-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文件应该有,所以安装应该正常工作!

+2

不能相信这没有更多upvotes。解决了我的问题。 – Sebastian