所以我在进行 apt-get upgrade 时出现了这个错误
Setting up nodejs (0.10.30-1chl1~trusty1) ...
update-alternatives: error: alternative link /usr/bin/node is already managed by nodejs
dpkg: error processing package nodejs (--configure): subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing: nodejs
E: Sub-process /usr/bin/dpkg returned an error code (1)
注意:“nodejs --version”有效,我得到一个干净的“v0.10.30”但“node --version”没有,因为没有链接。
到目前为止,我已经尝试过:
- 完全删除 nodejs 并重新安装
- 我在删除 nodejs 后手动删除了指向 nodejs 的链接/usr/bin/node,因为它仍然存在并且问题与更新替代方案有关
- 使用“update-alternatives --config nodejs”(我第一次使用它时出现故障并修复了它,但它没有解决问题。此后该错误没有再次出现)。
最佳答案
其他答案没有解决我的设置问题,可能是因为我使用的是 NodeSource存储库而不是官方存储库。
但我只是先删除了 nodejs 组的所有“替代方案”:
sudo update-alternatives --remove-all nodejs
在那之后,sudo apt-get install nodejs
就开始工作了。
关于node.js - 安装/升级 nodejs v0.10.30 时出现 "update-alternatives"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25094718/