【问题标题】:I trying to json-server by npm install -g json-server, but everytime I get an error我试图通过 npm install -g json-server 来 json-server,但每次我得到一个错误
【发布时间】:2021-11-01 12:50:14
【问题描述】:

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:\Users\7386-85615SG 2913642\AppData\Local\npm-cache\_logs\2021-09-03T06_29_38_211Z-debug.log

【问题讨论】:

  • 您需要授予当前用户权限,或者您可以使用当前用户安装节点。

标签: node.js json npm node-modules npm-install


【解决方案1】:

尝试运行以下命令: npm config set unsafe-perm=true

如果这对您不起作用,请尝试在 this 的帮助下将当前用户的文件夹权限更改为 C:\Program Files\nodejs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-23
    • 2013-09-15
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 2020-07-16
    • 2021-08-25
    • 1970-01-01
    相关资源
    最近更新 更多