I. Installing Node.
js
1. Download the latest version of Node.js Installer here.
2. Run the installer.
3. Follow the installer steps, and click the next button. Finally, click the Install button to run the
installer. When it finishes, click Finish.
4. Restart your system/machine.
5. At last, verify whether you have properly installed Node.js in your window, run the following
command in “Command Prompt”:
type node -v command, the system should display the Node.js version installed on your system.
type npm -v command, the system should display the NPM version installed on your system.
II. Installing JSON Server
1. Create a folder, for example: “d:\api-mocker”
2. Open “Node.js Command prompt”, and go to the folder by running command cd /d D:\ api-
mocker
3. Run command npm init , it will take a while to process, press Enter for everything. Finally, enter
‘yes’ for last step. It will create package.json file in your folder. (You are creating a new project
here)
4. Run command npm install json-server , this will install and add json-server as a package into your
project
5. Next step is creating a database file. You create a <file-name>.json that stores the data of the
mock database in JSON format. Let’s add some data to the file. For example, let’s name the file
mockerDB.json.
6. Open “package.json” file. In “scripts” key, add "start": "json-server --watch mockerDB.json"
7. Run command npm run start -- for starting the server, and it will load data from mockerDB.json
When it finished, you should have the Mock REST API running at http://localhost:3000