Hemang Joshi
Hemang Joshi

Reputation: 334

I trying to json-server by npm install -g json-server, but everytime I get an error

Image of the error This is the error that I am continuously getting after numerous tries. I tried removing node cache, I re-installed node.js but couldn't find success. However, whenever I am running it with administrator or root, I am able to install it. So why is this happening?

I have provided the screenshot of my error, however, still, I will provide the error in writing.

npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_modules\json-server
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\json-server'
npm ERR!  [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\json-server'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Program Files\\nodejs\\node_modules\\json-server'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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!     C:\Users\7386-85615SG 2913642\AppData\Local\npm-cache\_logs\2021-09-03T06_29_38_211Z-debug.log

Upvotes: 2

Views: 667

Answers (1)

Harshit Rastogi
Harshit Rastogi

Reputation: 2112

Try running this command: npm config set unsafe-perm=true

If that doesn't work for you, try changing the folder permissions for your current user for C:\Program Files\nodejs with the help of this

Upvotes: 1

Related Questions