我试图通过 npm install -g json-server json-server,但每次我都收到错误

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

Image of the error 这是我经过多次尝试后不断遇到的错误。我尝试删除节点缓存,重新安装 node.js 但没有成功。 但是,只要我是 运行 管理员或 root,我就可以安装它。那为什么会这样呢?

我已经提供了错误的屏幕截图,但是,我仍然会以书面形式提供错误。

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:\Users86-85615SG 2913642\AppData\Local\npm-cache\_logs21-09-03T06_29_38_211Z-debug.log

尝试运行这个命令: npm config set unsafe-perm=true

如果这对您不起作用,请尝试在 this

的帮助下更改 C:\Program Files\nodejs 当前用户的文件夹权限