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

发布于 2024-10-15 19:16:46 字数 1411 浏览 7 评论 0原文

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

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');

但最新版本。是固定的,所以这实际上不是必要的(参见下面的答案)。

I just installed node by cloning the git repo + make && make install. I then installed npm, and used npm to install express (seems like it fetches Connect automatically since it's a dependency). However, when trying to start a simple express example I get the error message:

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)

It seems someone has the same problem here: http://groups.google.com/group/express-js/browse_thread/thread/287086bd30f79cf1/adbb5c669872e45a
but the conclusion seems to be that one needs connect installed (which I have).
I've checked that I have the following files at least:

/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

Anyone have a clue?


Resolved

Added

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

But the newest rev. is fixed, so this shouldn't really be necessary (see answer below).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沐歌 2024-10-22 19:16:46

看起来这是 Express 中的一个 bug 。安装最新版本 1.0.5 为我解决了这个问题。

It seems like it was a bug in express. Installing the latest version, 1.0.5, fixed this problem for me.

百变从容 2024-10-22 19:16:46

听起来您没有包含 npm 目录的 require 路径。使用 require.paths 来修改它。

更多信息:

http://jherdman.github.com/2010 -04-05/understanding-nodejs-require.html

It sounds like you don't have your require path including your npm directory. Use require.paths to modify that.

Some more info:

http://jherdman.github.com/2010-04-05/understanding-nodejs-require.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文