问题在Ubuntu 16.04
问题描述:
安装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
而且从我在这里有点失落。有人知道该从这里做什么吗?
答
在我通过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
我希望这可以帮助有同样问题的其他人。
答
我建议你重新安装的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 -v
和npm -v
来验证安装。
答
参考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
检查'这npm' –