Nodejs / Express“原型”错误
我在尝试启动我的节点应用程序时出现以下错误:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据对您问题的评论,您可以发布您正在使用的代码吗?您很可能缺少
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听起来您缺少一些依赖项。将 package.json 文件添加到项目目录的根目录
然后,从项目目录运行 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
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.我通过从头开始并使用旧版本 0.4.8 重新安装节点来解决这个问题。
I solved this by starting from scratch and re-installing node again with an older version 0.4.8.