简体   繁体   中英

Nodejs / Express 'prototype' error

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

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

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.

我从头开始解决此问题,并使用旧版本0.4.8重新安装节点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM