This error seems common on windows boxes, but my Amazon Linux EC2 instance is throwing this error when I npm install pg:
這個錯誤在Windows機器上似乎很常見,但是當我在安裝pg時,我的Amazon Linux EC2實例會拋出此錯誤:
../src/binding.cc:1:23: fatal error: pg_config.h: No such file or directory
#include
^
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.
我在Amazon Linux 2014.03上,它是一個運行節點0.10.28的微實例。
Postgres 9.2.7 is installed from the Amazon repos. Specifically, the postgresql9* packages.
Postgres 9.2.7是從亞馬遜回購安裝的。具體來說,是postgresql9 *包。
On a fresh updatedb, locate pg_config returns
在新的updatedb上,找到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
But locate pg_config.h returns nothing.
但是找到pg_config.h什么都不返回。
Any ideas?
1 个解决方案
#1
7
The postgresql9, postgresql9-libs, and postgresql9-server were installed by default, but not postgresql9-devel.
postgresql9,postgresql9-libs和postgresql9-server默認安裝,但不是postgresql9-devel。
The header files required by node-postgres are in the missing development package. The following steps fixed my problem:
node-postgres所需的頭文件位於缺少的開發包中。以下步驟解決了我的問題:
Remove the node-postgres directory:
刪除node-postgres目錄:
$ rm -rf node_modules/pg
$ 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):
從repos安裝postgres開發包(仔細地匹配你的版本 - 在postgres上,亞馬遜的回購是一團糟):
$ sudo yum install postgresql9-devel
$ sudo yum install postgresql9-devel
Reinstall node-postgres (I'm doing it locally, you might be using the -g option):
重新安裝node-postgres(我在本地做,你可能正在使用-g選項):
$ npm install pg
$ npm install pg
The pg_config.h file should be there, so the installation should work fine!
pg_config.h文件應該在那里,所以安裝應該正常工作!