我想将nodejs和npm 1.4升级到最新版本。我设法将我的nodejs升级到10.0.40,但是我的npm无法更新。所以我决定将它们全部删除并重新安装最新版本。现在不仅我不能安装最新版本,但我无法安装我以前的版本。每次我尝试安装它都会给我这个错误:
$ sudo apt-get install npm
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:
npm : Depends: nodejs but it is not going to be installed
Depends: nodejs-dev
Depends: node-request but it is not going to be installed
Depends: node-mkdirp but it is not going to be installed
Depends: node-minimatch but it is not going to be installed
Depends: node-semver but it is not going to be installed
Depends: node-ini but it is not going to be installed
Depends: node-graceful-fs but it is not going to be installed
Depends: node-abbrev but it is not going to be installed
Depends: node-nopt but it is not going to be installed
Depends: node-fstream but it is not going to be installed
Depends: node-rimraf but it is not going to be installed
Depends: node-tar but it is not going to be installed
Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我什么时候才能安装最新版本?
答案 0 :(得分:1)
基于相对有限的信息,我建议您从NodeSource ppa中完全删除并重新安装节点。
将sudo apt-get purge nodejs
删除节点,然后按instructions here。
对于Ubuntu,卸载并重新安装当前nodejs + npm的完整命令序列将是(node 4.x):
sudo apt-get purge nodejs
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
这将完全删除您的Node.js安装,然后从另一个(最新的)源重新安装。这个过程应该很简单,但如果您不了解它的行为,请自行承担使用风险。
答案 1 :(得分:0)
尝试卸载软件包,
sudo apt-get remove npm
更新文件,
sudo apt-get update
然后重新安装
sudo apt-get install npm
如果审核有问题
npm audit fix
答案 2 :(得分:0)
我通过重新启动计算机、sudo apt-get update、sudo apt install npm 解决了这个问题,现在它可以工作了