【问题标题】:Can't install json-server无法安装 json-server
【发布时间】:2022-01-01 23:13:59
【问题描述】:

我正在尝试安装 JSON-Server,但它不起作用!

我使用了以下命令:npm install -g json-server

这是错误信息:

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/json-server
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/json-server'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/json-server'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/json-server'
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.

【问题讨论】:

  • 您是否在错误中看到“权限被拒绝”?您是否阅读了错误的最后 3 行?

标签: npm json-server


【解决方案1】:

尝试在命令前使用 sudo

sudo npm install -g json-server

【讨论】:

  • 这行得通,但为什么呢?哈哈
  • @EgorUlybin 阅读了错误代码的最后 3 行 ;-) 最好的问候!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-07-03
  • 1970-01-01
  • 2011-07-10
  • 2018-08-05
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
相关资源
最近更新 更多