所以我在做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”没有,因为没有链接。
到目前为止,我已经尝试过:
答案 0 :(得分:7)
其他答案没有解决我的设置问题,可能是因为我使用的是NodeSource存储库而不是官方存储库。
但我首先删除了nodejs组的所有“替代方案”:
sudo update-alternatives --remove-all nodejs
之后,sudo apt-get install nodejs
刚刚起作用。
答案 1 :(得分:1)
我真的鼓励你使用nvm在你的ubuntu机器上安装Node.js(https://github.com/creationix/nvm)。这样,任何Node.js版本的安装都变得非常容易。
答案 2 :(得分:1)
可能您安装了较旧版本的NodeJS,升级时会出现冲突。
使用/usr/bin/node
的唯一软件包是nodejs-legacy
,因此,除非您自己创建了该链接,或者从您需要删除的软件包源安装了NodeJS:
$ sudo apt-get purge nodejs-legacy nodejs
之后只需重新安装NodeJS,更新并升级您的软件:
$ sudo apt-get install nodejs
$ sudo apt-get update && sudo apt-get upgrade
从输出中你给出的PPA的NodeJS版本优先于另一个,所以你不应该在安装它时遇到任何问题。