Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Creating Your First Server | Section
Building APIs with Express.js

bookCreating Your First Server

メニューを表示するにはスワイプしてください

To start using Express, you first need to install it in your project.

In your project folder, run:

npm install express

After installation, you can create a basic server.

const express = require("express");

const app = express();

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});

Here's what happens in this code:

You import Express and create an application using express(). Then you start the server using app.listen().

The number 3000 is the port where your server will run. When the server starts, it listens for incoming requests on that port.

To run the server, execute your file with Node.js. If everything works, you will see the message in the terminal.

At this point, the server is running, but it does not handle any requests yet. That will be added in the next step.

question mark

What does app.listen(3000) do?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  2

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  2
some-alt