To get started quickly with Express, you can use the Express generator which will create an application skeleton for you.
First, install it globally with npm:
npm install express-generator -g
You may need to put sudo
before this command if you get a "permission denied" error.
Once the generator is installed, you can start a new project like this:
express my_app
The above command will create a folder called my_app
with a package.json
file, an app.js
file, and a few subfolders like bin
, public
, routes
, views
.
Now navigate to the folder and install the dependencies:
cd first_app
npm install
If you're on Linux or macOS, you can start the app like this:
DEBUG=myapp:* npm start
Or, if you're on Windows:
set DEBUG=myapp:* & npm start
Now, load http://localhost:3000/ in your web browser and you should see the words "Welcome to Express".