Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Node.js + Express.js does not run

I am trying to learn to create web apps with nodejs and expressjs, following the getting started guide found at the expressjs website, under the heading Using express(1) to generate an app.

I generated an app using the express-generator plugin, ran npm install, and then attempted to run the application by using node app (I also tried node app.js for good measure. When running either of these commands, there is no output to the terminal whatsoever.

I also tried to debug the application using node debug app, with the following results:

< debugger listening on port 5858
connecting... ok
break in app.js:1
  1 var express = require('express');
  2 var http = require('http');
  3 var path = require('path');
debug> cont
program terminated
debug> cont
App isn't running... Try `run` instead
debug> 

I did find a file bin/www that seemed to contain the code to start the server, and, sure enough, running node bin/www succeeded in starting the application.

What am I missing here?

like image 339
Tyler Avatar asked Mar 06 '14 05:03

Tyler


People also ask

How do I start node JS Express app?

Project SetupCreate an empty folder and name it node express. Open the newly created directory in VS Code, and inside the terminal, type npm init to initialize the project. Press the “Enter” key to leave the default settings as they are.

Does node Run Express?

Installing Express Firstly, install the Express framework globally using NPM so that it can be used to create a web application using node terminal. body-parser − This is a node. js middleware for handling JSON, Raw, Text and URL encoded form data.

How do I know if ExpressJS is running?

In windows you can simply go to the Task Manager and check for node in the application list. If it is there then it is running in the machine.

What is the default port for ExpressJS?

I know that Express apps default to port 3000.


1 Answers

Looks like the way to start app has changed. Instead of node app you should now do

npm start

More details here https://github.com/expressjs/generator

like image 110
vinayr Avatar answered Sep 29 '22 16:09

vinayr