Question

I have installed Express using:
nvm install -g express && nvm install -g express-generator
Then I ran:
express -c stylus my_app
to create new blank app, and install dependencies:
nvm install
But, when I node app.js my output is blank/clean and node exits

$ node app.js
$ 

What am i doing wrong?

Était-ce utile?

La solution 2

Create new folder, place new app.js in folder. And put the following code in app.js:

var app = require('express')();
app.listen(8080, function (err) {
      if (err) { 
         console.log(err);
      } else {
         console.log("App started at port 8080");
      }    
});

This is blank express app. And then run in command line: node app.js

Autres conseils

For future people who encounter this question: make sure you call app.listen([port number]). If you don't call .listen(), your code will simply instantiate the app and then exit immediately.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top