3

I've installed json-server by using:

npm install -g json-server

then I created a db.json like this:

{
  "employees": [
    {
      "id": 1,
      "first_name": "Sebastian",
      "last_name": "Eschweiler",
      "email": "[email protected]"
    },
    {
      "id": 2,
      "first_name": "Steve",
      "last_name": "Palmer",
      "email": "[email protected]"
    },
    {
      "id": 3,
      "first_name": "Ann",
      "last_name": "Smith",
      "email": "[email protected]"
    }
  ]
}

I watch json-server by:

json-server --watch db.json 

but it does not work. The message in terminal is:

cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

What happened?

3
  • 1
    If you go to the link and enable this learn.microsoft.com/en-gb/powershell/module/… Commented Jun 9, 2020 at 16:12
  • how to enable? Can you help me? Commented Jun 10, 2020 at 8:46
  • i'm seted : Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -> A . But not work it message: is denied. To change the execution policy for the default (LocalMachine) scope, start Windows PowerShell with the "Run as administrator" option. To change the execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser" Commented Jun 10, 2020 at 8:54

1 Answer 1

2

You can install json-server as a dev dependency

npm install -D json-server

then you can run the below command

npx json-server --watch db.json --port 3004

It will work.

Sign up to request clarification or add additional context in comments.

1 Comment

I already had a global install of json-server (I didn't use the -D flag) and was having trouble running the json-server command in Visual Studio Code's terminal, but running the npx command worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.