使用Egg.js编写RestfulAPI接口(一)创建web工程

1.检查node是否已经安装

C:\Users\SYJ>node -v
v10.15.0

2.检查npm是否已经安装

C:\Users\SYJ>npm -v
6.14.11

3.创建并进入egg-example目录

C:\Users\SYJ>mkdir egg-example && cd egg-example

4.快速初始化egg标准web工程

C:\Users\SYJ\egg-example>npm init egg --type=simple

5.安装依赖

C:\Users\SYJ\egg-example>npm install

6.启动web工程,控制台显示启动成功,端口7001

C:\Users\SYJ\egg-example>npm run dev

> example@1.0.0 dev C:\Users\SYJ\egg-example
> egg-bin dev

[egg-ts-helper] create typings\app\controller\index.d.ts (7ms)
[egg-ts-helper] create typings\config\index.d.ts (20ms)
[egg-ts-helper] create typings\config\plugin.d.ts (5ms)
[egg-ts-helper] create typings\app\index.d.ts (1ms)
2021-02-25 10:49:01,034 INFO 4472 [master] node version v10.15.0
2021-02-25 10:49:01,036 INFO 4472 [master] egg version 2.29.3
2021-02-25 10:49:03,056 INFO 4472 [master] agent_worker#1:6652 started (2013ms)
2021-02-25 10:49:05,343 INFO 4472 [master] egg started on http://127.0.0.1:7001 (4305ms)

7.打开浏览器访问:http://127.0.0.1:7001/

 

posted @ 2021-02-25 14:34  xuebusi  阅读(539)  评论(0编辑  收藏  举报