gpt4 book ai didi

macos - npm 安装成功,但 Node web.js 错误 w : "Error: Cannot find module"

转载 作者:太空宇宙 更新时间:2023-11-03 22:18:49 25 4
gpt4 key购买 nike

我正在努力让 Node 在新的 Mac 上运行。我下载安装在http://nodejs.org/

然后我 git 克隆了我的 Node 存储库,运行 npm install 和 npm update,然后运行 ​​Node web.js,然后出现错误:

$ node web.js 

Error: Cannot find module '/Users/me/Sites/mysite-node/node_modules/pg/lib/native/../../build/default/binding'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/Users/me/Sites/mysite-node/node_modules/pg/lib/native/index.js:12:12)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)

我是 Node 新手,对于去哪里查看有什么想法或建议吗?谢谢

最佳答案

您需要在计算机上安装 postgresql 库。例如,在 Fedora 下您可以:

yum install postgresql.x86_64
yum install postgresql-server.x86_64

如果您已经安装了 pg,则需要重建它:

npm rebuild pg

然后要验证终端上的一切是否正常,请输入:

node

然后在 Node REPL 中输入:

var pg = require('pg').native

并且您不应该收到错误

关于macos - npm 安装成功,但 Node web.js 错误 w : "Error: Cannot find module",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12127819/

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