This error seems common on windows boxes, but my Amazon Linux EC2 instance is throwing this error when I npm install pg
:
../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
I'm on Amazon Linux 2014.03, and it's a micro instance running node 0.10.28.
Postgres 9.2.7 is installed from the Amazon repos. Specifically, the postgresql9*
packages.
On a fresh updatedb
, locate pg_config
returns
/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
But locate pg_config.h
returns nothing.
Any ideas?
The postgresql9
, postgresql9-libs
, and postgresql9-server
were installed by default, but not postgresql9-devel
.
The header files required by node-postgres
are in the missing development package. The following steps fixed my problem:
Remove the node-postgres
directory:
$ rm -rf node_modules/pg
Install the postgres development package from the repos (match your version carefully - the Amazon repos are a mess when it comes to postgres):
$ sudo yum install postgresql9-devel
Reinstall node-postgres
(I'm doing it locally, you might be using the -g
option):
$ npm install pg
The pg_config.h
file should be there, so the installation should work fine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With