【问题标题】:can not install node-postgres [closed]无法安装 node-postgres [关闭]
【发布时间】:2014-02-12 06:52:22
【问题描述】:

我正在尝试为我的项目设置 node-postgres。但是,当我尝试安装它时,我不断收到这些 gyp 错误。如何让 node-postgres 识别出我的 pg_config 位于 /Library/PostgreSQL/9.3/bin/pg_config 中。因为我最喜欢的搜索引擎结果告诉我这样做:

➜  src git:(master) ✗ PG_CONFIG=/Library/PostgreSQL/9.3/bin/pg_config
➜  src git:(master) ✗ export PG_CONFIG
➜  src git:(master) ✗ sudo npm install pg
Password:
npm WARN package.json test@0.1.0 No repository field.
npm http GET https://registry.npmjs.org/pg
npm http 304 https://registry.npmjs.org/pg
npm http GET https://registry.npmjs.org/generic-pool/2.0.3
npm http GET https://registry.npmjs.org/buffer-writer/1.0.0
npm http GET https://registry.npmjs.org/pgpass/0.0.1
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/pgpass/0.0.1
npm http 304 https://registry.npmjs.org/buffer-writer/1.0.0
npm http 304 https://registry.npmjs.org/generic-pool/2.0.3
npm http GET https://registry.npmjs.org/split
npm http 304 https://registry.npmjs.org/split
npm http GET https://registry.npmjs.org/through
npm http 304 https://registry.npmjs.org/through

> pg@2.11.1 install /Users/me/test/src/node_modules/pg
> node-gyp rebuild || (exit 0)

/bin/sh: pg_config: command not found
gyp: Call to 'pg_config --libdir' returned exit status 127.
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/me/test/src/node_modules/pg
gyp ERR! node -v v0.10.24
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
pg@2.11.1 node_modules/pg
├── nan@0.6.0
├── generic-pool@2.0.3
├── buffer-writer@1.0.0
└── pgpass@0.0.1 (split@0.2.10)
➜  src git:(master) ✗

【问题讨论】:

  • 我在“直接涉及编程或编程工具”的工作流程中的开发环境中遇到了这个错误,所以一点也不离题!

标签: node.js postgresql node-postgres


【解决方案1】:

看起来节点构建工具没有查看PG_CONFIG env var:

/bin/sh: pg_config: 找不到命令

改为将其添加到PATH

export PATH=/Library/PostgreSQL/9.3/bin:$PATH

【讨论】:

  • 你太棒了!看来我必须深入研究这些导出路径;我只是不明白他们的目的
  • @Egidius 如果命令在路径上,您可以在不指定完整路径的情况下运行它。所以/bin/ls 可以简单地运行为ls,因为/binPATH 上。工具链、编译/配置脚本等使用它来发现可以安装在系统任何位置的东西的位置。
猜你喜欢
  • 1970-01-01
  • 2018-03-12
  • 2018-03-29
  • 2015-11-28
  • 2019-09-08
  • 2019-03-16
相关资源
最近更新 更多