【问题标题】:How to running command npm run in visual studio code?如何在 Visual Studio 代码中运行命令 npm run?
【发布时间】:2018-04-13 21:45:50
【问题描述】:

我正在尝试通过观看视频来做到这一点。但我在视频中的 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."    
    }    
  ]
}

【问题讨论】:

    标签: visual-studio rest npm npm-scripts


    【解决方案1】:

    您似乎缺少color-convert 模块。尝试运行npm install --save color-convert。此模块将作为依赖项添加到您的 package.json 中。

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 2016-06-04
      • 1970-01-01
      • 2020-01-17
      • 2021-10-31
      • 1970-01-01
      • 2020-07-16
      • 2017-10-06
      • 1970-01-01
      相关资源
      最近更新 更多