0
0
Expressframework~5 mins

Express installation and setup - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command do you use to create a new Node.js project before installing Express?
You use npm init -y to quickly create a new Node.js project with default settings.
Click to reveal answer
beginner
How do you install Express in your project?
Run npm install express in your project folder to add Express as a dependency.
Click to reveal answer
beginner
What is the basic code to create an Express app and start a server on port 3000?
```js
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});
```
Click to reveal answer
beginner
Why do we use app.listen() in Express?
app.listen() tells Express to start the server and listen for requests on a specific port.
Click to reveal answer
beginner
What file usually contains the Express app setup code?
Typically, the main file is named index.js or app.js where Express is set up and the server starts.
Click to reveal answer
Which command installs Express in your Node.js project?
Aexpress install
Bnpm start express
Cnode install express
Dnpm install express
What does app.listen(3000) do in an Express app?
ACreates a new route
BStops the server
CStarts the server on port 3000
DInstalls Express
Which file is commonly used to write Express setup code?
Astyle.css
Bindex.js
Cpackage.json
DREADME.md
What is the purpose of npm init -y before installing Express?
ACreates a new Node.js project with default settings
BInstalls Express globally
CStarts the Express server
DUpdates npm to latest version
How do you send a simple 'Hello World!' response in Express?
Ares.send('Hello World!')
Bconsole.log('Hello World!')
Capp.listen('Hello World!')
Dnpm install 'Hello World!'
Describe the steps to install Express and start a basic server.
Think about commands and basic code to get Express running.
You got /6 concepts.
    Explain why we need to use app.listen() in an Express application.
    Consider what happens after writing routes.
    You got /4 concepts.