【问题标题】:Failed to install json-server on Ubuntu 20.04无法在 Ubuntu 20.04 上安装 json-server
【发布时间】:2021-03-18 05:21:25
【问题描述】:

我正在尝试安装json-server,但一再失败,这让我感到绝望。现在需要帮助来解决问题。在我在 Ubunto-20.04 操作系统上使用的命令下方。

  1. 安装的 Nodejs 版本: v14.16.0
  2. 安装的 NPM 版本: 6.14.10

虽然首先,我使用了最新版本的nodejs 15x,但我也遇到了安装json-server的错误,下面的命令用于安装json-server

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

我已经使用上述所有命令来安装json-server,但我每次都遇到错误,如下所示,

这里是错误

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

注意:附加文件中也添加了错误,高级感谢您的帮助。

【问题讨论】:

  • 试试sudo

标签: javascript json reactjs npm


【解决方案1】:

您可以尝试使用 sudo,例如“sudo npm install -g json-server”或使用“chmod -r 777 /usr/local/lib/node_modules”授予写入权限。我认为 sudo 选项更适合即时许可。

【讨论】:

  • 谢谢兄弟。 sudo npm install -g json-server 命令有效。
【解决方案2】:

您正在以正确的权限运行命令,您应该对 node_modules 进行 chmod 并使用 sudo 再次运行该命令。

【讨论】:

  • 非常感谢兄弟,这是一个很大的帮助。使用 sudo 命令解决。
猜你喜欢
  • 2020-11-28
  • 2020-10-03
  • 2021-05-24
  • 2021-11-28
  • 2022-08-17
  • 1970-01-01
  • 1970-01-01
  • 2021-08-18
  • 2021-12-08
相关资源
最近更新 更多