app.set('port', port) 'TypeError: undefined is not a function'. Beginner, need ideas

后端 未结 6 941
春和景丽
春和景丽 2021-02-04 04:12

I\'m an amateur learning to build with node.js. I\'ve been following a tutorial to create my first node.js app. It worked perfectly until I entered \'npm start\'. The log is:

6条回答
  •  温柔的废话
    2021-02-04 04:52

    At the bottom of your app.js:

    app.set('port', process.env.PORT || 26398); //<--- replace with your port number
    
    // Server
    var server = http.createServer(app);
    server.listen(app.get('port'), function(){
        console.log('Express server listening on port ' + app.get('port'));
    });
    
    module.exports = app;
    

提交回复
热议问题