简体   繁体   English

在 Ubuntu 中安装 npm

[英]Installing npm in Ubuntu

I am truly struggling to install npm .我真的很难安装npm I have installed the nodejs package successfully, but still my operating system Ubuntu 15.10 (Wily Werewolf) doesn't recognize the npm command like it is shown below, even though after several update attempts with sudo apt-get update :我已经成功安装了nodejs包,但我的操作系统Ubuntu 15.10 (Wily Werewolf) 仍然无法识别npm命令,如下所示,即使在使用sudo apt-get update进行了几次更新尝试后也是如此:

user@user-T420:~$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
The following packages were automatically installed and are no longer required:
  authbind diffstat hardening-includes libapt-pkg-perl libarchive-zip-perl
  libbonobo2-0 libbonobo2-common libcamel-1.2-29 libclass-accessor-perl
  libclone-perl libedataserver-1.2-15 libemail-valid-perl libgles1-mesa
  libgnome2-0 libgnome2-bin libgnome2-common libidl-common libidl0
  libindicate5 libio-pty-perl libio-string-perl libipc-run-perl
  libnet-dns-perl libnet-domain-tld-perl libnet-ip-perl liborbit2
  libperlio-gzip-perl libpoppler19 libqt5x11extras5 libsdl-image1.2
  libtext-levenshtein-perl libtiff4 libva-drm1 libxcb-composite0 libxcb-xv0
  linux-headers-4.2.0-16 linux-headers-4.2.0-16-generic
  linux-image-4.2.0-16-generic linux-image-extra-4.2.0-16-generic patchutils
  t1utils vlc-plugin-notify vlc-plugin-samba
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
user@user-T420:~$ npm -v
The program 'npm' is currently not installed. You can install it by typing:
sudo apt-get install npm

user@user-T420:~$ 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-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

user@user-T420:~$ sudo apt-get install nodejs-dev
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:
 nodejs-dev : Depends: libssl-dev (>= 1.0.0g) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

user@user-T420:~$ sudo apt-get install libssl-dev
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:
 libssl-dev : Depends: libssl1.0.0 (= 1.0.1-4ubuntu5.36) but 1.0.2d-0ubuntu1.4 is to be installed
              Depends: zlib1g-dev but it is not going to be installed
              Recommends: libssl-doc but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

user@user-T420:~$ sudo apt-get install zlib1g-dev
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:
 zlib1g-dev : Depends: zlib1g (= 1:1.2.3.4.dfsg-3ubuntu4) but 1:1.2.8.dfsg-2ubuntu4 is to be installed
E: Unable to correct problems, you have held broken packages.

It looks an infinite tree of dependencies.它看起来是一棵无限的依赖树。 Is there a solution to fix it?有解决办法吗?

If this would be of any help, here's my sources.list file:如果这有任何帮助,这是我的sources.list文件:

#############################################################
############### OFFICIAL UBUNTU REPOSITORIES ################
#############################################################

###### Ubuntu Main Repositories
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse

###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

###### Ubuntu Partner Repository
deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partner

###### Ubuntu Extras Repository
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main

Use aptitude instead of apt-get.使用aptitude而不是 apt-get。 It is more intelligent.它更聪明。 It not only will handle downgrading conflicting packages for you, but it will make a series of recommendations asking you which of many possible suggested working scenarios you would like.它不仅会为您处理降级冲突包,还会提出一系列建议,询问您想要哪些可能的建议工作场景。

sudo aptitude install myNewPackage

If you don't have aptitude on your machine yet, get it with如果您的机器上还没有 aptitude,请使用

sudo apt-get install aptitude

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

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