首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Ubuntu 20.04上安装json-server失败

在Ubuntu 20.04上安装json-server失败
EN

Stack Overflow用户
提问于 2021-03-18 05:21:25
回答 2查看 1.2K关注 0票数 3

我正在尝试安装json-server,但一再失败,这使我无望。现在需要帮助才能解决问题。下面是我在ubto-20.04操作系统上使用的命令。

  1. Installed Nodejs版本: v14.16.0
  2. Installed 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,但在每一个时刻,我都会遇到错误,如下所示,

这里是错误

代码语言:javascript
复制
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

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-03-18 06:20:06

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

票数 5
EN

Stack Overflow用户

发布于 2021-03-18 06:13:39

如果您使用正确的权限运行该命令,您应该使用chmod node_modules并使用sudo再次运行该命令。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66685210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档