Command json-server --watch db.json is not working - it returns"'json-server' command not found"
Solution 1
Try:
npx json-server --watch db.json
Solution 2
Check if this might help you.
Open the git bash(assume you have on your local machine) and execute below command: alias json-server="<..../node_modules/.bin/json-server.cmd>" ---> IGNORE <, > symbols and .... is the location where your node_modules folder is present
Then run json-server --watch db.json
Angelo Fonseca
Updated on June 12, 2022Comments
-
Angelo Fonseca almost 2 years
I set a JSON file to use as a little practice database, but I can't run the server.
I've already tried to install (and reinstall) json-server global and locally
npm install -g json-server
andnpm install json-server
and then runjson-server --watch db.json
, but it doesn't work.I've also tried to set a script in the package.json file
"load": "json-server --watch db.json"
and run the scriptnode load
.But nothing seems to work and I keep getting in return the message:
"'json-server' command not found"
or, in Portuguese:
"'json-server' não é reconhecido como um comando interno ou externo, um programa operável ou um arquivo em lotes".
How can I fix this?
-
Marco over 3 yearsthis helped me - but why?
-
Alexander Cherednichenko about 2 yearsthis way with npx also works for me 👍