Nodejs / Express“原型”错误

发布于 2024-12-08 11:44:34 字数 863 浏览 0 评论 0原文

我在尝试启动我的节点应用程序时出现以下错误:

TypeError: Cannot read property 'prototype' of undefined

完整错误:

at Object.<anonymous> (/home/node/node_modules/express/lib/express/server.js:87:44)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Object.<anonymous> (/home/node/node_modules/express/lib/express/index.js:28:31)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)

我已注意到关于同一错误的上一个问题: Express 框架给出了一个非常奇怪的错误。我尝试安装旧版本的 connect,但这不起作用,并且收到了相同的错误。

节点版本:v0.5.9-pre

I have the following error while trying to start my node app:

TypeError: Cannot read property 'prototype' of undefined

Full error:

at Object.<anonymous> (/home/node/node_modules/express/lib/express/server.js:87:44)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Object.<anonymous> (/home/node/node_modules/express/lib/express/index.js:28:31)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)

I have noted this previous question on the same error: Express framework giving a very strange error. I tried to install the older version of connect, but this did not work and I received the same error.

Node version: v0.5.9-pre

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

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

发布评论

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

评论(3

睫毛溺水了 2024-12-15 11:44:34

根据对您问题的评论,您可以发布您正在使用的代码吗?您很可能缺少 app.use 语句

Based on the comments on your question, could you post the code you are using? you are most likely missing an app.use statement

岁吢 2024-12-15 11:44:34

听起来您缺少一些依赖项。将 package.json 文件添加到项目目录的根目录

{
    "name": "myproject"
  , "version": "0.0.1"
  , "private": true
  , "dependencies": {
      "express": "2.4.6"
    , "ejs": ">=0.4.3" 
  }
}

然后,从项目目录运行 npm install -d 。如果您使用jade而不是ejs,请将package.json上的该行更改为jade,它是当前版本。

It sounds like you're missing some dependencies. Add a package.json file to the root of your project directory

{
    "name": "myproject"
  , "version": "0.0.1"
  , "private": true
  , "dependencies": {
      "express": "2.4.6"
    , "ejs": ">=0.4.3" 
  }
}

Then, run npm install -d from the project directory. If you're using jade instead of ejs, change that line on the package.json to jade and it's current version.

东风软 2024-12-15 11:44:34

我通过从头开始并使用旧版本 0.4.8 重新安装节点来解决这个问题。

I solved this by starting from scratch and re-installing node again with an older version 0.4.8.

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