繁体   English   中英

在Ubuntu 14.04上安装Node 5.x和最新的或正在运行的npm

[英]Install Node 5.x and latest or working npm on Ubuntu 14.04

我在Azure上有一个Ubuntu 14.04虚拟机。 我只是尝试升级node和npm,但似乎已损坏它。 我已删除并清除了缓存,并多次清除了缓存。 将安装nodejs,但不会安装npm。

> node -v
v5.1.1

我为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: node-abbrev (>= 1.0.4) but it is not going to be installed
   Depends: node-ansi 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 (>= 2.1.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-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我的apt-get更新如下所示:

> sudo apt-get update
Ign http://debian.neo4j.org stable/ InRelease
Ign http://azure.archive.ubuntu.com trusty InRelease
Ign http://repo.mongodb.org trusty/mongodb-org/3.0 InRelease
Hit http://security.ubuntu.com trusty-security InRelease
Get:1 http://debian.neo4j.org stable/ Release.gpg [819 B]
Hit http://azure.archive.ubuntu.com trusty-updates InRelease
Hit http://azure.archive.ubuntu.com trusty Release.gpg
Hit http://repo.mongodb.org trusty/mongodb-org/3.0 Release.gpg
Hit http://debian.neo4j.org stable/ Release
Hit http://repo.mongodb.org trusty/mongodb-org/3.0 Release
Hit http://azure.archive.ubuntu.com trusty Release
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://azure.archive.ubuntu.com trusty-updates/main Sources
Hit http://repo.mongodb.org trusty/mongodb-org/3.0/multiverse amd64 Packages
Hit http://debian.neo4j.org stable/ Packages
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://azure.archive.ubuntu.com trusty-updates/universe Sources
Hit http://azure.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://azure.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://azure.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://azure.archive.ubuntu.com trusty-updates/universe Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://azure.archive.ubuntu.com trusty/main Sources
Hit http://azure.archive.ubuntu.com trusty/universe Sources
Hit http://azure.archive.ubuntu.com trusty/main amd64 Packages
Hit http://azure.archive.ubuntu.com trusty/universe amd64 Packages
Ign http://debian.neo4j.org stable/ Translation-en_US
Ign http://debian.neo4j.org stable/ Translation-en
Hit http://azure.archive.ubuntu.com trusty/main Translation-en
Hit http://azure.archive.ubuntu.com trusty/universe Translation-en
Ign http://azure.archive.ubuntu.com trusty/main Translation-en_US
Ign http://repo.mongodb.org trusty/mongodb-org/3.0/multiverse Translation-en_US
Ign http://azure.archive.ubuntu.com trusty/universe Translation-en_US
Ign http://repo.mongodb.org trusty/mongodb-org/3.0/multiverse Translation-en
Hit https://deb.nodesource.com trusty InRelease
Hit https://deb.nodesource.com trusty/main Sources
Hit https://deb.nodesource.com trusty/main amd64 Packages
Get:2 https://deb.nodesource.com trusty/main Translation-en_US
Ign https://deb.nodesource.com trusty/main Translation-en_US
Ign https://deb.nodesource.com trusty/main Translation-en
Fetched 819 B in 6s (131 B/s)
Reading package lists... Done

你可以试试这个

sudo apt-get purge node
sudo apt-get purge npm
sudo apt-get autoremove node
sudo apt-get autoremove npm
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash

=>关闭并重新打开终端以开始使用NVM

source ~/.profile
nvm ls-remote

如果看到任何错误,请安装git(sudo apt-get install git)

nvm install 5.0 //or any of the version you want to use
nvm use 5.0 ///use the version which ever you want and need not install npm  as it will installed with it

希望这对您有帮助:)

解决此问题的最简单方法; 是从nodejs.org下载最新版本的压缩包,然后将nodenpm二进制文件添加到您的路径中。

为确保一切顺利,首先删除通过软件包系统安装的版本,下载tar,解压缩,然后将所得路径添加到$PATH

  1. sudo apt-get remove --purge node
  2. sudo apt-get remove --purge npm
  3. cd ~ && wget "https://nodejs.org/dist/v5.1.1/node-v5.1.1-linux-x64.tar.gz"
  4. tar xvzf node-v5.1.1-linux-x64.tar.gz && cd node-v5.1.1-linux-x64
  5. PATH=$PATH:~/node-v5.1.1-linux-x64/bin

现在,只需将bin/目录添加到$PATH并重新启动Shell。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM