【发布时间】:2019-08-28 01:50:25
【问题描述】:
我正在设置一个 json-server 并安装它并将其分配给我的 npm start 命令,就像这样
"scripts": {
"start": "json-server -p 3001 -w db.json"
但是每次我在终端上输入 npm start 时都会出现这个错误
> api-server@1.0.0 start C:\Work\React-projects\streams\api-server
> json-server -p 3001 -w db.json
'json-server' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! api-server@1.0.0 start: `json-server -p 3001 -w db.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api-server@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Abdelaziz\AppData\Roaming\npm-cache\_logs\2019-04-06T09_07_30_796Z-debug.log
【问题讨论】:
-
你是如何安装 json-server 的?
-
@ArnaudChrist 我什么都试过了``` npm install -g json-server --save ```
-
对于访问的人..您可以直接使用 NPX 观看 json 文件,甚至无需安装 json-server 像这样 "npx json-server --watch ./data/filename.json"
标签: reactjs npm json-server