如何在Windows中运行json-server?

时间:2019-01-30 14:03:47

标签: windows cmd json-server

我已经在Windows中使用npm安装了json-server。现在,当我尝试从Windows命令提示符运行json-server命令时,出现以下错误:json-server is not recognized as an internal or external command, operable program or batch file.

有人在这里有什么需要更改的信息吗?

3 个答案:

答案 0 :(得分:0)

尝试一下(对于5.2.0之后的npm版本): npx json-server db.json

答案 1 :(得分:0)

使用npm尝试一下:

json-server --watch db.json

答案 2 :(得分:0)

  1. 在 PowerShell 中运行它 npm install -g json-server
  2. 运行json-server .\db.json

此后,您的服务器应该在 http://localhost:3000/posts

上运行