簡體   English   中英

在 Node.js 和 2 個其他 node.js 問題中安裝 Postgres 模塊時出錯

[英]Error installing Postgres module in Node.js and 2 other node.js questions

我在為 Node.js 安裝 Postgres 數據庫模塊時遇到問題,每次運行命令“npm install pg”時都會出現以下錯誤:
C:>npm install pg
npm http GET https://registry.npmjs.org/pg
npm http 200 https://registry.npmjs.org/pg
npm http GET https://registry.npmjs.org/pg/-/pg-0.12.1.tgz
npm http 200 https://registry.npmjs.org/pg/-/pg-0.12.1.tgz
npm http GET https://registry.npmjs.org/generic-pool/2.0.2
npm http 200 https://registry.npmjs.org/generic-pool/2.0.2
npm http GET https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz
npm http 200 https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz

pg@0.12.1 install C:\\node_modules\\pg
node-gyp rebuild || (exit 0)

C:\\node_modules\\pg>node "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\node-gyp-b
in\\....\\node_modules\\node-gyp\\bin\\node-gyp.js" rebuild
'pg_config' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to 'pg_config --libdir' returned exit status 1. while trying to load b
inding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\\Program Files\\nodejs\\node_module
s\\npm\\node_modules\\node-gyp\\lib\\configure.js:420:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 5.1.2600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\\node_modules\\pg
gyp ERR! node -v v0.8.17
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok
pg@0.12.1 node_modules\\pg
└── generic-pool@2.0.2

這個錯誤發生在我的工作機器(linux/windows box)和我家里的個人機器(windows)上。 有任何想法嗎?

另外我應該提到我已經安裝了 Python 2.7.3。

您在 Windows 上:

'pg_config' is not recognized as an internal or external command, operable program or batch file.

所以我建議你得到一個預先構建的 pg 模塊的二進制文件。 在 Windows 上編譯東西是......很有趣。

直接錯誤是pg_config可執行文件不在PATH ,但是在您修復它之后會有更多錯誤。 獲取預構建的可執行文件,除非您計划踏上探索之旅和發誓之旅。

在PATH變量中指定Postgres bin文件夾,然后不要忘記以管理員權限重新啟動cmd.exe

安裝 postgres db ( https://www.postgresql.org/download/ ) 並確保它的 bin 文件夾路徑存在於環境變量中

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM