2016-12-01 143 views
0

安裝NPM當試圖用一個簡單的sudo apt-get install npm我得到以下錯誤在Ubuntu 16.04安裝NPM:問題在Ubuntu 16.04

The following packages have unmet dependencies: 
npm : Depends: nodejs but it is not going to be installed 
     Depends: node-abbrev (>= 1.0.4) but it is not going to be installed 
     Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed 
     Depends: node-ansi-color-table but it is not going to be installed 
     Depends: node-archy but it is not going to be installed 
     Depends: node-block-stream but it is not going to be installed 
     Depends: node-fstream (>= 0.1.22) but it is not going to be installed 
     Depends: node-fstream-ignore but it is not going to be installed 
     Depends: node-github-url-from-git but it is not going to be installed 
     Depends: node-glob (>= 3.1.21) but it is not going to be installed 
     Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed 
     Depends: node-inherits but it is not going to be installed 
     Depends: node-ini (>= 1.1.0) but it is not going to be installed 
     Depends: node-lockfile but it is not going to be installed 
     Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed 
     Depends: node-minimatch (>= 0.2.11) but it is not going to be installed 
     Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed 
     Depends: node-gyp (>= 0.10.9) but it is not going to be installed 
     Depends: node-nopt (>= 3.0.1) but it is not going to be installed 
     Depends: node-npmlog but it is not going to be installed 
     Depends: node-once but it is not going to be installed 
     Depends: node-osenv but it is not going to be installed 
     Depends: node-read but it is not going to be installed 
     Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed 
     Depends: node-request (>= 2.25.0) but it is not going to be installed 
     Depends: node-retry but it is not going to be installed 
     Depends: node-rimraf (>= 2.2.2) but it is not going to be installed 
     Depends: node-semver (>= 2.1.0) but it is not going to be installed 
     Depends: node-sha but it is not going to be installed 
     Depends: node-slide but it is not going to be installed 
     Depends: node-tar (>= 0.1.18) but it is not going to be installed 
     Depends: node-underscore 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. 

我檢查是否安裝節點:

$ which nodejs 
/usr/bin/nodejs 
$ which node 
/usr/bin/node 

而且從我在這裏有點失落。有人知道該從這裏做什麼嗎?

+0

檢查'這npm' –

回答

0

在我通過installing nvm解決它的端部(調整的版本號與當前版本):

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash 
export NVM_DIR="$HOME/.nvm" # OR LOG OUT AND BACK IN AGAIN 

我然後用於NVM安裝最新版本的節點,這也與安裝它的NPM。

nvm install node 

我希望這可以幫助有同樣問題的其他人。

-1

我建議你重新安裝的NodeJS因爲

NPM:依賴:的NodeJS,但它不會在錯誤要安裝

說的NodeJS沒有安裝(安裝不正確)。

我建議你從https://nodejs.org/en/download/

然後

tar -zxvf node-v6.9.1.tar.gz 

cd node-v6.9.1 

./configure 

make 

sudo make install 

的NodeJS下載源代碼節點v6.9.1.tar.gz NPM會按照上述步驟安裝在您的計算機上。

您可以在命令提示符處使用node -vnpm -v來驗證安裝。

0

參考Node Package Manager got corrupted

你可以做以下

sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages 
sudo apt-get install curl 
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - 
sudo apt-get install -y nodejs 

此工程在我的Ubuntu 16.04.2