无法在 ubuntu 命令行中安装 nodejs

无法在 ubuntu 命令行中安装 nodejs

我尝试过这个:sudo apt install nodejs

出现错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nodejs : Depends: python-minimal but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

答案1

确保您的/etc/apt/sources.list文件正确。

运行下一个命令来找出您使用的发布版本:

cat /etc/lsb-release | grep RELEASE

然后按照以下链接之一更改您的/etc/apt/sources.list文件:

19.10 来源.列表
18.04 来源.列表
16.04 来源.列表

您可以备份旧sources.list文件,sudo mv /etc/apt/sources.list /etc/apt/sources.list.bk然后通过提供的链接之一粘贴其内容来创建新文件。

然后做

sudo apt clean && sudo apt update && sudo apt install npm nodejs node-abbrev node-ansi node-rimraf

然后再试一次。

还要确保文件夹下没有可疑的存储库,/etc/apt/sources.list.d/这些存储库可能包含nodejs不包含所需依赖项的较新版本。

相关内容