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?
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.
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.
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.
I know that Express apps default to port 3000.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With