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?
✗ Incorrect
The correct command is
npm install express to add Express to your project.What does
app.listen(3000) do in an Express app?✗ Incorrect
app.listen(3000) starts the server and listens for requests on port 3000.Which file is commonly used to write Express setup code?
✗ Incorrect
index.js or app.js usually contain the Express app setup code.What is the purpose of
npm init -y before installing Express?✗ Incorrect
npm init -y quickly creates a new Node.js project with default settings.How do you send a simple 'Hello World!' response in Express?
✗ Incorrect
Use
res.send('Hello World!') inside a route to send a response.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.