安装/升级nodejs v0.10.30时出现"update-alternatives"错误

gue*_*nam 5 installation upgrade node.js ubuntu-14.04

所以我在做apt-get升级时遇到这个错误

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)
Run Code Online (Sandbox Code Playgroud)

注意:"nodejs --version"工作,我得到一个干净的"v0.10.30",但"node --version"没有,因为没有链接.

到目前为止,我尝试过:

  • 完全删除nodejs和新安装
  • 我删除了nodejs之后手动删除了链接/ usr/bin/node到nodejs,因为它仍然存在且问题与update-alternatives有关
  • 使用"update-alternatives --config nodesjs"(第一次使用它时,某些东西被破坏并修复了,但它没有解决问题.那个错误自那时起就没有出现过).

小智 7

其他答案没有解决我的设置问题,可能是因为我使用的是NodeSource存储库而不是官方存储库.

但我首先删除了nodejs组的所有"替代方案":

sudo update-alternatives --remove-all nodejs
Run Code Online (Sandbox Code Playgroud)

在那之后,一个sudo apt-get install nodejs刚刚工作.


jse*_*nck 0

我真的鼓励你使用 nvm 在你的 ubuntu 机器上安装 Node.js ( https://github.com/creationix/nvm )。这样,任何 Node.js 版本的安装都变得非常容易。