0
votes

I'm getting this error when I run npm run json: server.

npm ERR! missing script: json:

when I open the log file, this is what it says:

0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'json:', 1 verbose cli 'server' ] 2 info using [email protected] 3 info using [email protected] 4 verbose stack Error: missing script: json: 4 verbose stack at run (C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\lib\run-script.js:151:19) 4 verbose stack at C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\lib\run-script.js:61:5 4 verbose stack at C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:115:5 4 verbose stack at C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:402:5 4 verbose stack at checkBinReferences_ (C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:357:45) 4 verbose stack at final (C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:400:3) 4 verbose stack at then (C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:160:5) 4 verbose stack at C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:348:12 4 verbose stack at C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16 4 verbose stack at tryToString (fs.js:513:3) 5 verbose cwd C:\Users\IanP\Documents\GitHub\JSONSERVER 6 verbose Windows_NT 10.0.15063 7 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "json:" "server" 8 verbose node v8.2.1 9 verbose npm v5.5.1 10 error missing script: json: 11 verbose exit [ 1, true ]

My package.json has the following

   {
  "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"
  }
}

I did not modify anything since it's last successful run. When I was starting to work the following day, suddenly the error.

TIA.

1

1 Answers

0
votes

Rename the "json:server" in scripts to any of the JSON verified characters.

: are generally used to separate key-value pair. Even in the log it's pointing out to the same (see verbose line 7). 7 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\IanP\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "json:" "server"

So, it would be good idea to replace "json:server" with "json-server" or using camel-Case insted like "jsonServer".

Hope this helps.