0

I installed json-server using command npm install json-server, In my package.json, I can see json-server is installed but when I tried to start it, it gets error that:

json-server : command not found

I also tried sudo npm install json-server and sudo npm install -g json-server but nothing works.

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
Raza Ellahi
  • 379
  • 2
  • 7
  • 20

1 Answers1

1

login as root and install it using

sudo su
npm install -g json-server
exit
sancelot
  • 1,905
  • 12
  • 31
  • 2
    If one can sudo, why not just `sudo npm install...` ? – Til Jan 21 '19 at 12:21
  • @Tiw, because you will not have the same set of environment variables using sudo su. and particularly the PATH environment variable. the later one will reflect root user's one – sancelot Jan 21 '19 at 13:40
  • Thank you!! This worked for me. I had tried a lot of solutions but was getting the same error. – Omkar Kulkarni Mar 08 '19 at 21:50