json-server服务器的启动步骤

112 阅读1分钟

1,全局安装json-server

npm i json-server -g

2,新增一个文件夹,创建db.json文件,文件内容如下

{ 
"posts": [ { "id": 1, "title": "json-server", "author": "typicode" } ], "comments": [ { "id": 1, "body": "some comment", "postId": 1 } ], 
"profile": { "name": "typicode" } 
}

3,本窗口打开cmd

启动项目 json-server --watch db.json