在 Manjaro 上更新包时无法提交事务(冲突文件)

Aja*_*vas 15 linux archlinux node.js manjaro pacman-package-manager

sudo pacman -Syu

我尝试在我的 Manjaro Linux 上使用 pacman 更新所有软件包,pacman 一定会尽一切努力下载所有可用软件包的最新更新,在检查文件冲突后,它会抛出

...
(126/126) checking keys in keyring  100%
(126/126) checking package integrity 100%
(126/126) loading package files 100%
(126/126) checking for file conflicts
error: failed to commit transaction (conflicting files)
npm: /usr/lib/node_modules/npm/lib/exec/get-workspace-location-msg.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/@npmcli/git/lib/utils.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/balanced-match/.github/FUNDING.yml exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/just-diff/index.d.ts exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/just-diff/index.tests.ts exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/CHANGELOG.md exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/LICENSE exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/README.md exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/cache-install-dir.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/manifest-missing.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/no-tty.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/run-script.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/package.json exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/LICENSE exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/README.md exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/index.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/package.json exists in filesystem
Errors occurred, no packages were upgraded.
Run Code Online (Sandbox Code Playgroud)

我是否应该对我认为是要覆盖的全局安装的节点模块的node_modules 执行任何特定操作?

Aja*_*vas 20

首先删除 npm 包,然后删除 node_modules 目录是我用来完成这项工作的解决方法。但是,我不确定这是否是正确的解决方案。您可以在进行完整更新之前执行类似的操作,然后再次安装 npm。

$ sudo pacman -Rns npm
$ sudo rm -R /usr/lib/node_modules/npm/
$ sudo rm -R /usr/share/man/man1/
$ sudo pacman -Syyu
$ sudo pacman -S npm
Run Code Online (Sandbox Code Playgroud)

  • 什么是 man/man1 删除? (3认同)

小智 17

你可以sudo pacman -S npm --overwrite '/usr/lib/node_modules/npm/*'

答案作者的评论:

它基本上通过覆盖文件来解决冲突。在您的情况下,冲突的文件都位于/usr/lib/node_modules/npm/因此*将匹配所有这些文件。无需手动删除它们,否则rm -r会使包处于不一致的状态。之后使用sudo pacman -Syyu.

  • 您可以将此添加到您的答案中吗? (2认同)