javascript - 无法在 Ubuntu 20.04 上安装 json-server
问题描述
我正在尝试安装json-server
但一再失败,这让我感到绝望。现在需要帮助来解决问题。在我在 Ubunto-20.04 操作系统上使用的命令下方。
- 安装的Nodejs版本: v14.16.0
- 安装的 NPM 版本: 6.14.10
虽然首先,我使用了15x的最新版本的 nodejs,但我也遇到了安装错误json-server
,下面的命令用于安装json-server
npm install json-server -g
npm install -g json-server
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,例如“sudo npm install -g json-server”,或者使用“chmod -r 777 /usr/local/lib/node_modules”授予写入权限。我认为 sudo 选项更适合即时许可。
推荐阅读
- javascript - 复选框值返回并添加到字符串
- python - SOAP 调用响应只得到最后一个结果 - Python
- javascript - TypeError: firebase.analytics is not a function when mocking with jest
- html - 如何将视频插入到 HTML 文本中?
- java - JSF 列表取决于返回 nullPointer 的选定值
- java - 使用 BufferReader '\n' 读取后不会被接受为换行符,如何解决这个问题?
- python - 新项目 :: adv. 通讯录,但我遇到了一些问题
- java - SOAP WsSecurity 数字签名使用 CXF 和 WSS4J for X509Certificate
- javascript - 将 React Navigation v5 身份验证错误传递回注册/登录屏幕
- python - Gensim 模型:类“FileNotFoundError”