2

How start app in express js (nodejs)? TypeError:app.set is not a function. Console.log screen

screen

var express = require('express');
var app = express();

app.get('/', function (req, res) {
res.send('Hello World!');
});

var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
});
2
  • 1
    Where is the app.set line in your code? Commented Jan 5, 2016 at 8:31
  • @skypjack, app.set only in bin/www file (default file). var port = normalizePort(process.env.PORT || '3000'); app.set('port', port); Commented Jan 5, 2016 at 8:36

1 Answer 1

4

Solved a problem: 1. add module.exports = app;

Sign up to request clarification or add additional context in comments.

1 Comment

I already have that line in my code, but still the error. Any idea how to solve it ??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.