我正试图通过观看视频来做到这一点。但是在视频中我在09:40分出现错误。
以下是video link
我在终端上运行此命令; npm run json:server
我收到以下错误。
我的终端错误:
C:\Users\Yavuz\Desktop\JSONSERVER>npm run json:server
> jsonserver@1.0.0 json:server C:\Users\Yavuz\Desktop\JSONSERVER
> json-server --watch db.json
module.js:540
throw err;
^
Error: Cannot find module 'color-convert'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Yavuz\Desktop\JSONSERVER\node_modules\ansi-styles\index.js:2:22)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jsonserver@1.0.0 json:server: `json-server --watch db.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsonserver@1.0.0 json:server 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\Yavuz\AppData\Roaming\npm-cache\_logs\2018-04- 13T21_32_40_798Z-debug.log
的package.json
{
"name": "jsonserver",
"version": "1.0.0",
"description": "Fake REST API for testing",
"main": "index.js",
"scripts": {
"json:server": "json-server --watch db.json"
},
"author": "",
"license": "ISC",
"dependencies": {
"json-server": "^0.12.1"
}
}
db.json
{
"users":[
{
"id":"1",
"firstName":"John",
"lastName":"Doe",
"email":"john@gmail.com",
"age":34,
"companyId":"1"
},
{
"id":"2",
"firstName":"Mark",
"lastName":"Doe",
"email":"mark@gmail.com",
"age":32,
"companyId":"2"
}
],
"companies":[
{
"id":"1",
"name":"Apple",
"description":"This is very good firm."
},
{
"id":"2",
"name":"Microsoft",
"description":"This is good firm."
}
]
}
答案 0 :(得分:0)
看起来你错过了color-convert
模块。尝试运行npm install --save color-convert
。此模块将作为依赖项添加到package.json
中。