express icon indicating copy to clipboard operation
express copied to clipboard

app.address does not exist

Open btakita opened this issue 14 years ago • 7 comments

$ npm list express
npm WARN ls doesn't take positional args. Try the 'search' command
[email protected] /Users/btakita/workspace/garland-express
├── [email protected]  extraneous
├─┬ [email protected]  invalid
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├─┬ [email protected]  extraneous
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
├── [email protected] 
└── [email protected] 

This is from a fresh run of

express --template mustache -c sass -s
$ node app.js 

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Object function app(req, res){ app.handle(req, res); } has no method 'address'
    at Server.<anonymous> (/Users/btakita/workspace/garland-express/app.js:37:69)
    at Server.g (events.js:156:14)
    at Server.emit (events.js:64:17)
    at Array.0 (net.js:777:10)
    at EventEmitter._tickCallback (node.js:192:40)

btakita avatar May 13 '12 19:05 btakita

hmm it shouldn't be generating anything with app.address(), try maybe updating again with npm install -g express

tj avatar May 14 '12 15:05 tj

I have the exact same error. btakita, did you ever resolve this issue?

arkitex avatar Jun 29 '12 15:06 arkitex

in express 2.x I have been using app.address().port to display the port that is in use, now in 3.x I also get the error message has no method 'address'

djhojd avatar Jun 29 '12 23:06 djhojd

var server = http.createServer(app); server.address() - express "apps" are no longer servers, just functions

tj avatar Jun 29 '12 23:06 tj

check out the migration guide in the wiki

tj avatar Jun 29 '12 23:06 tj

The migration guide doesn't mention any "address()" method ?

strk avatar Jul 16 '12 13:07 strk

.address() is a node thing, but yeah I get asked that a lot i'll add something to the migration guide

tj avatar Jul 16 '12 16:07 tj