我尝试过很多次,过去也遇到过这个问题,当时我试图在另一个项目中安装不同的节点包。我没有使用其他包继续前进,但现在我陷入困境。
我试过了:
- 取消设置工作目录中所有内容的读取属性
- 使用
sudo
命令安装软件包并更改文件所有者 - 在 Windows 中禁用受控访问
- 我在网上发现的许多其他命令根本无法被识别。
我想我必须删除并重新安装 Ubuntu。我不确定此时还能做什么。就上下文而言,我对 Ubuntu 和一般使用终端的经验有限。我使用它进行 Web 开发,因此npm install
,运行和测试几乎是我所用的全部。现在它不起作用了。
~/development/code/phase-2/react-hooks-react-router-code-along$ npm install react-router-dom@5
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/type-fest
npm ERR! dest /home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/.type-fest-KEXQjTnf
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/type-fest' -> '/home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/.type-fest-KEXQjTnf'
npm ERR! [Error: EACCES: permission denied, rename '/home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/type-fest' -> '/home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/.type-fest-KEXQjTnf'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/type-fest',
npm ERR! dest: '/home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/.type-fest-KEXQjTnf'
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/bambam320/.npm/_logs/2022-09-13T06_04_28_484Z-debug-0.log
更新:我检查了权限,最后终于可以更改权限了,但这不是权限问题。它试图重命名一个拥有所有权限的文件。我不确定它为什么会返回错误,包本身很常见。
file: home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/type-fest
#owner: bambam320
#group: bambam320
user::rwx
group::rwx
other::rwx
> File: /home/bambam320/development/code/phase-2/react-hooks-react-router-code-along/node_modules/type-fest
> Size: 512 Blocks: 0 IO Block: 512 directory
Device: 2h/2d Inode: 1125899909662013 Links: 1
Access: (0777/drwxrwxrwx) Uid: ( 1000/bambam320) Gid: ( 1000/bambam320)
Access: 2022-09-13 02:04:08.504282200 -0400
Modify: 2022-09-11 02:36:32.761662300 -0400
Change: 2022-09-13 02:04:07.077342300 -0400
Birth: -