如何确定要安装哪个包?

如何确定要安装哪个包?

在 Mac 上,由于我曾经node运行过 NodeJS,所以我假设我在 Ubuntu 上也会做同样的事情(就像gccGNU C 编译器一样)。

于是我输入node,结果显示

The program 'node' can be found in the following packages:
 * node
 * nodejs-legacy
Try: sudo apt-get install <selected package>

看起来确实如此node

但是如果我使用apt-cache search ^node$搜索其描述,它什么都不显示。如果我使用apt-cache search ^nodejs$,那么它会显示nodejs - evented I/O for V8 javascript

看起来确实如此nodejs

(此外,apt-cache show node没有显示任何内容,而apt-cache show nodejs显示了很多信息,所以似乎更有可能是nodejs。但是,当我输入时node,它说“可以在以下包中找到程序‘node’:node,nodejs-legacy”?)

在这种情况下,你怎么知道哪一个是正确的呢?我对知道哪一个是正确的不太感兴趣,但我更感兴趣的是学习如何从目前给出的信息中找出答案。

-- 更新:

根据 @muru 的要求,这是来自

$ sudo apt-get update

Hit http://us.archive.ubuntu.com wily InRelease
Hit http://us.archive.ubuntu.com wily-updates InRelease               
Hit http://security.ubuntu.com wily-security InRelease                 
Hit http://us.archive.ubuntu.com wily-backports InRelease
Hit http://us.archive.ubuntu.com wily/main Sources                     
Hit http://security.ubuntu.com wily-security/main Sources   
Hit http://us.archive.ubuntu.com wily/restricted Sources    
Hit http://security.ubuntu.com wily-security/restricted Sources  
Hit http://us.archive.ubuntu.com wily/universe Sources        
Hit http://us.archive.ubuntu.com wily/multiverse Sources      
Hit http://security.ubuntu.com wily-security/universe Sources 
Hit http://us.archive.ubuntu.com wily/main amd64 Packages         
Hit http://us.archive.ubuntu.com wily/restricted amd64 Packages   
Hit http://security.ubuntu.com wily-security/multiverse Sources   
Hit http://us.archive.ubuntu.com wily/universe amd64 Packages     
Hit http://security.ubuntu.com wily-security/main amd64 Packages  
Hit http://us.archive.ubuntu.com wily/multiverse amd64 Packages   
Hit http://us.archive.ubuntu.com wily/main i386 Packages          
Hit http://security.ubuntu.com wily-security/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily/restricted i386 Packages      
Hit http://us.archive.ubuntu.com wily/universe i386 Packages        
Hit http://security.ubuntu.com wily-security/universe amd64 Packages
Hit http://us.archive.ubuntu.com wily/multiverse i386 Packages 
Hit http://us.archive.ubuntu.com wily/main Translation-en      
Hit http://security.ubuntu.com wily-security/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily/multiverse Translation-en    
Hit http://security.ubuntu.com wily-security/main i386 Packages    
Hit http://us.archive.ubuntu.com wily/restricted Translation-en    
Hit http://security.ubuntu.com wily-security/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily/universe Translation-en      
Hit http://security.ubuntu.com wily-security/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/main Sources         
Hit http://us.archive.ubuntu.com wily-updates/restricted Sources   
Hit http://security.ubuntu.com wily-security/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe Sources      
Hit http://us.archive.ubuntu.com wily-updates/multiverse Sources    
Hit http://security.ubuntu.com wily-security/main Translation-en
Hit http://us.archive.ubuntu.com wily-updates/main amd64 Packages
Hit http://security.ubuntu.com wily-security/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-updates/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe amd64 Packages
Hit http://security.ubuntu.com wily-security/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-updates/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/main i386 Packages   
Hit http://security.ubuntu.com wily-security/universe Translation-en
Hit http://us.archive.ubuntu.com wily-updates/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/main Translation-en
Hit http://us.archive.ubuntu.com wily-updates/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-updates/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-updates/universe Translation-en
Hit http://us.archive.ubuntu.com wily-backports/main Sources
Hit http://us.archive.ubuntu.com wily-backports/restricted Sources
Hit http://us.archive.ubuntu.com wily-backports/universe Sources
Hit http://us.archive.ubuntu.com wily-backports/multiverse Sources
Hit http://us.archive.ubuntu.com wily-backports/main amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/universe amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/main i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/main Translation-en
Hit http://us.archive.ubuntu.com wily-backports/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-backports/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-backports/universe Translation-en
Reading package lists... Done

$ apt-cache show node | grep -i Desc
$                           # <-- nothing is showing up as result

$ apt-cache show node
N: Can't select versions from package 'node' as it is purely virtual
N: No packages found

答案1

数字海洋

要在 Ubuntu 上安装node,请执行以下操作:

  1. 更新您当前的软件包:

    sudo apt-get update
    
  2. 添加源(对于较新的版本,node 也建议从这里下载):

    wget -c https://deb.nodesource.com/setup | sudo bash -
    
  3. 安装node.js

    sudo apt-get install nodejs
    
  4. 您可能还需要build-essential更多功能(npm 所需):

    sudo apt-get install build-essential
    

答案2

跑步apt-cache show 应该显示他们的描述:

$ apt-cache show node | grep -i Desc
Description: Amateur Packet Radio Node program (transitional package)
Description-md5: 1278ed271672fd829c99361f93f468da
$ apt-cache show nodejs | grep -i Desc
Description: evented I/O for V8 javascript
Description-md5: e507fb472d7cdaceffc5b285a62d5c1b

如果没有,你仍然可以访问软件包索引。只需前往http://packages.ubuntu.com/<package-name>

如您所见,在两个页面中,包的名称旁边都有描述。

相关内容