firebase - EACCES:全局安装 NPM 包时权限被拒绝
问题描述
我需要为 firebase 托管安装 firebase 工具。所以我查看了文档并运行了命令sudo npm install -g firebase-tools
,但这出现在我的终端中。
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated xmldom@0.1.31: Deprecated due to CVE-2021-21366 resolved in 0.5.0
npm WARN deprecated har-validator@5.1.5: this library is no longer supported /usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
npm ERR! code EACCES
npm ERR! syscall /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, acces '/usr/local/lib'
npm ERR! {[Error: EACCES: permission denied, acces '/usr/local/lib']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, acces \'/usr/local/lib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib' }
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 as root/Administrator.
解决方案
此问题与权限有关,可以通过安装节点版本管理器来解决。
如果您在尝试全局安装软件包时看到EACCES 错误,您可以:
使用节点版本管理器重新安装 npm(推荐),
或者
手动更改 npm 的默认目录
这是避免权限问题的最佳方法。要使用节点版本管理器重新安装 npm,请按照“下载和安装 Node.js 和 npm ”中的步骤操作。在安装节点版本管理器之前,您无需删除当前版本的 npm 或 Node.js。
推荐阅读
- c# - 在 C# 中从 BLE 设备读取数据
- javascript - 当一个div在悬停时翻译它时如何隐藏文本?
- java - 在 Spring Boot 中创建外键 - H2 数据库
- bash - 在 Bash 脚本中使用参数调用程序时遇到问题
- linux - 是否可以为 Linux/ARM 构建和运行 Go 插件?
- java - 考虑在你的配置中定义一个 'org.o7planning.sbshoppingcart.service.UserDetailsServiceImpl' 类型的 bean
- sql - 多个键上的 FULL OUTER JOIN
- sorting - 如何根据模板类型的向量进行排序
- java - 如何在 List 中实例化和存储值
> - python - 如何有效地计算可能组合的数量(在每种类型中至少选择一种时)?