2015-11-27 165 views
-1

我想将我的nodejs和npm 1.4升级到最新版本。我设法将我的nodejs升级到10.0.40,但我的npm无法更新。所以我决定一起删除它并重新安装最新版本。现在,我不仅可以安装最新版本,但我不能安装我以前的一个。每次我尝试安装它给我这个错误:无法在Ubuntu上安装npm 12.04

$ 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. 

我怎么能安装最新版本,当我根本没有它?

+1

“我设法升级我的nodejs”是什么意思?你究竟做了什么?这可能是相关的信息... –

+0

意味着我在我的电脑上降级了我的节点 – user2938948

+0

这没有什么帮助。您正在寻求帮助,并应尽力提供所有相关信息。你升级的步骤是什么?你是否从源代码安装?你升级了debian'nodejs'包吗?你从另一个ppa安装了吗? –

回答

1

基于相对有限的信息,我建议您从NodeSource ppa中完全删除并重新安装节点。

这将是sudo apt-get purge nodejs删除节点,然后按照instructions here

对于Ubuntu的,命令的全序列卸载并重新安装电流+的NodeJS NPM将是(节点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

我在安装npm时遇到了很多问题。节点会安装,但npm不会因为某些原因。这是唯一可行的方法!谢谢 – rex