2015-11-27 229 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