Failed to install json-server on Ubuntu 20.04

I am trying to install json-server but failed repeatedly and it makes me hopeless. Now need help to makes the solution. Below the command which I have used on the Ubunto-20.04 Operating System.

  1. Installed Nodejs version: v14.16.0
  2. Installed NPM version: 6.14.10

And Although firstly, I used the latest version of nodejs which was 15x but I also faced an error to install json-server and below’s command used to install json-server

  1. npm install json-server -g
  2. npm install -g json-server
  3. npm i json-server

I have used all of the above command to install json-server but in every moments I faced error and that’s given below,

Here is error

checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/imdadul/.npm/_logs/2021-03-18T04_32_41_181Z-debug.log

Note: The error also added in the attached file and Advanced thanks for your helps. enter image description here

Answer

You could try with sudo like “sudo npm install -g json-server” or give write permission with “chmod -r 777 /usr/local/lib/node_modules”. I think that sudo option is better for instant permisson.

Leave a Reply

Your email address will not be published. Required fields are marked *