gpt4 book ai didi

javascript - 在 Node.js 中安装 Postgres 模块时出错以及其他 2 个 node.js 问题

转载 作者:行者123 更新时间:2023-11-29 14:12:07 27 4
gpt4 key购买 nike

我在为 Node.js 安装 Postgres 数据库模块时遇到问题,每次运行命令“npm install pg”时都会收到以下错误:

C:>npm install pg<br/>
npm http GET <a href="https://registry.npmjs.org/pg" rel="noreferrer noopener nofollow">https://registry.npmjs.org/pg</a><br/>
npm http 200 <a href="https://registry.npmjs.org/pg" rel="noreferrer noopener nofollow">https://registry.npmjs.org/pg</a><br/>
npm http GET <a href="https://registry.npmjs.org/pg/-/pg-0.12.1.tgz" rel="noreferrer noopener nofollow">https://registry.npmjs.org/pg/-/pg-0.12.1.tgz</a><br/>
npm http 200 <a href="https://registry.npmjs.org/pg/-/pg-0.12.1.tgz" rel="noreferrer noopener nofollow">https://registry.npmjs.org/pg/-/pg-0.12.1.tgz</a><br/>
npm http GET <a href="https://registry.npmjs.org/generic-pool/2.0.2" rel="noreferrer noopener nofollow">https://registry.npmjs.org/generic-pool/2.0.2</a><br/>
npm http 200 <a href="https://registry.npmjs.org/generic-pool/2.0.2" rel="noreferrer noopener nofollow">https://registry.npmjs.org/generic-pool/2.0.2</a><br/>
npm http GET <a href="https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz" rel="noreferrer noopener nofollow">https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz</a><br/>
npm http 200 <a href="https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz" rel="noreferrer noopener nofollow">https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz</a><br/>



<blockquote>
<p>pg@0.12.1 install C:\node_modules\pg<br/>
node-gyp rebuild || (exit 0)<br/></p>
</blockquote>

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

这个错误发生在我的工作机器(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 上,但在您修复它之后会有更多错误。获取预构建的可执行文件,除非您计划踏上探索之旅。

关于javascript - 在 Node.js 中安装 Postgres 模块时出错以及其他 2 个 node.js 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14576240/

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