Issue Starting json-server Using npm start

230 Views Asked by At

Hello Stack Overflow community,

I'm currently learning json-server and have encountered an issue when attempting to start it within my project folder. Here's a brief overview of the problem:

I have installed json-server in my project folder, as shown in [img 1]. I created a new db.json file for testing, as depicted in [img 2]. When I run the script npm start, I encounter an error, and json-server fails to start, as seen in [img 3]. I've attempted to install json-server in a different folder and even installed it globally on my computer, but the issue persists with the same error. I'm unsure how to resolve this error, and I'm hoping to get guidance on how to make it work when running npm start with the start script as json-server --watch db.json.

Thank you for your assistance!

My error

> [email protected] start D:\react-f8\react-dom\another-json-server
> json-server --watch db.json

file:///D:/react-f8/react-dom/another-json-server/node_modules/steno/lib/index.js:39
        this.#nextPromise ||= new Promise((resolve, reject) => {
                          ^^^

SyntaxError: Unexpected token '||='
    at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `json-server --watch db.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start 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\HungVV37\AppData\Roaming\npm-cache\_logs\2024-02-02T03_00_19_551Z-debug.log  

I try to install again json-server in another folder, or install global on my computer but it doesn't work. It always throws the same error.

1

There are 1 best solutions below

0
iann muller On

Run into same issue. You need to update node to 15 or newer