🌐 Nodejs.cn

5.x API 参考

本部分概述了 Express 5.x 中用于构建 Web 应用和 HTTP 服务的模块和 API。

🌐 This section provides an overview of the modules and APIs available in Express 5.x for building web applications and HTTP services.

index.cjs
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('hello world');
});
app.listen(3000);

Note

Express 5.x 需要 Node.js 18 或更高版本

🌐 Express 5.x requires Node.js 18 or higher.

在 express v5.x 中,你可以使用 express() 函数创建的应用实例来定义路由、配置中间件,以及开始处理 HTTP 请求。API 组织如下几个部分:

🌐 With express v5.x, you can define routes, configure middleware, and start handling HTTP requests using the application instance created by the express() function. The API is organized into the following sections: