gpt4 book ai didi

javascript - 无法在 Ubuntu 20.04 上安装 json-server

转载 作者:行者123 更新时间:2023-12-05 01:30:51 25 4
gpt4 key购买 nike

我正在尝试安装 json-server 但多次失败,这让我感到绝望。现在需要帮助来制定解决方案。下面是我在 Ubunto-20.04 操作系统上使用过的命令。

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

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

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

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

Here is error

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

注意:错误也已添加到附件中,感谢您的帮助。 enter image description here

最佳答案

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

关于javascript - 无法在 Ubuntu 20.04 上安装 json-server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66685210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com