I already installed in other computers by npm the json-server. But on my MacBook Pro the command was run with successful and when I will execute the command json-server db.json is showed the message:
My versions:
I already installed in other computers by npm the json-server. But on my MacBook Pro the command was run with successful and when I will execute the command json-server db.json is showed the message:
My versions:
I did fix this following these steps:
https://gist.github.com/rcugut/c7abd2a425bb65da3c61d8341cd4b02d
I was having the same problem. Previously, I named the folder as json-server (same as the package name)
I changed the folder name and installed the package globally using
npm install -g json-server
It works perfectly fine now
Made the same mistake using VS Code. Entered in terminal->>
$ json-server --watch data/db.json <<-
Got the classic ->>
Error: ENOENT: no such file or directory, open 'data/db.json' <<-
Simple fix was to realize I needed to add the parent folder name in the terminal ->>
$ json-server --watch folder-name/data/db.json <<-
This opened a local host to my db.json file ->>
http://localhost:3000/projects <<-
Hope this helps someone that made the same simple mistake I did.
I too got this issue. while working on a frontend project(vue).
I don't know why it happens but I found a way around / solution.
go to your pakage.json file. go to "scripts" and add
"scripts": {
"fakeDB":"json-server --watch db.json"
},
you can change "fakeDB" to what ever you want and "json-server --watch " is used to run your json db file in my case its db.json