安装node+express时找不到模块connect/utils

dwbf0jvd  于 2023-05-28  发布在  Node.js
关注(0)|答案(2)|浏览(141)

我刚刚通过克隆git repo + make && make install安装了node。然后我安装了npm,并使用npm安装了express(似乎它会自动获取Connect,因为它是一个依赖项)。然而,当尝试启动一个简单的express示例时,我得到了错误消息:

Error: Cannot find module 'connect/utils'
at Function._resolveFilename (module.js:219:11)
at Function._load (module.js:171:25)
at require (module.js:246:19)
at Object.<anonymous> (/home/yngve/local/node/lib/node/.npm/express/1.0.3/package/lib/express/response.js:16:13)
at Module._compile (module.js:302:26)
at Object..js (module.js:308:10)
at Module.load (module.js:234:31)
at Function._load (module.js:201:10)
at require (module.js:246:19)
at Object.<anonymous> (/home/yngve/local/node/lib/node/.npm/express/1.0.3/package/lib/express/index.js:52:1)

似乎有人在这里遇到了同样的问题:http://groups.google.com/group/express-js/browse_thread/thread/287086bd30f79cf1/adbb5c669872e45a,但结论似乎是一个需要连接安装(我有)。我检查了我至少有以下文件:
/home/yngve/local/node/lib/node/.npm/connect/0.5.8/package/lib/connect/utils.js/home/yngve/local/node/lib/node/.npm/express/1.0.3/node_modules/connect/connect/utils.js
有人有线索吗?

已解决

添加

require.paths.unshift('<path_to_node>/lib/node/connect');

最新的Rev.是固定的,所以这应该不是真的必要的(见下面的答案)。

bq9c1y66

bq9c1y661#

好像是快递的bug。安装最新版本1.0.5,为我解决了这个问题。

ukdjmx9f

ukdjmx9f2#

这听起来像你没有你的require路径,包括你的npm目录。使用require.paths来修改它。
更多信息:
http://jherdman.github.com/2010-04-05/understanding-nodejs-require.html

相关问题