Pregunta

As you might know that new express.js version has came out and it contains most of the changes including restful routes etc. In previous version to run an app we use to set app.js in webstorm but now in express 4.0 to run an app npm is required npm start is command. Does any body know how to setup an express 4.0 app in webstrom to run from it?

¿Fue útil?

Solución

In your Configuration, go to "JavasScript file" and change it to this value: bin\www

Otros consejos

Click the 'Run' button (the green triangle), and in the console you should see: "Express server listening on port 3000". Then you can access your app at http://localhost:3000.

I found one hack for this. That is when you create new express.js 4.0 app you will notice that appname/bin/www.txt file get created which contains following code

var debug = require('debug')('my-application');
var app = require('../app');

app.set('port', process.env.PORT || 3000);

var server = app.listen(app.get('port'), function() {
  debug('Express server listening on port ' + server.address().port);
});

just comment out this line var app = require('../app'); copy that code and paste at bottom of your app.js i.e appname/app.js that's it now you run an app from node app.js

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top