该程序可以在以下软件包中找到

该程序可以在以下软件包中找到

当我mvn在终端中写入命令时,我收到此消息:

The program 'mvn' can be found in the following packages:
 * maven
 * maven2
Try: sudo apt-get install <selected package>

我也收到相同的命令消息node

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

我认为这意味着我安装了两个版本的 maven,并且node除了 nodejs 之外我还有另一个程序,它也有node与之关联的命令。

所以它希望我使用:

sudo apt-get install maven 

或者

sudo apt-get install maven2 

mvn命令与其中一个程序(的版本mavenmaven或永久关联maven2

现在有没有办法暂时使用mvnformaven或 for maven2?我的意思是我可以暂时选择其中一个maven或?maven2

答案1

命令mvn

在这种情况下mvn,您可以安装maven(v3,不是v1) 和maven2(v2) 并排:

sudo apt-get install maven maven2

您将得到两个二进制文件。

/usr/share/maven/bin/mvn
/usr/share/maven2/bin/mvn

要在两个二进制文件之间切换,请使用:

sudo update-alternatives --config mvn

例子

% mvn -version 
Apache Maven 2.2.1 (rdebian-17)
Java version: 1.8.0_45
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.19.0-22-generic" arch: "amd64" Family: "unix"

% sudo update-alternatives --config mvn
There are 2 choices for the alternative mvn (providing /usr/bin/mvn).

  Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/share/maven2/bin/mvn   200       auto mode
  1            /usr/share/maven/bin/mvn    150       manual mode
  2            /usr/share/maven2/bin/mvn   200       manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/share/maven/bin/mvn to provide /usr/bin/mvn (mvn) in manual mode


% mvn -version                         
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-22-generic", arch: "amd64", family: "unix"

命令node

对于node,这是不可能的,或者只能付出更大的努力:

% sudo apt-get install node nodejs-legacy
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:
 node : Conflicts: nodejs-legacy but 0.10.25~dfsg2-2ubuntu1 is to be installed
 nodejs-legacy : Conflicts: node but 0.3.2-7.4 is to be installed
E: Unable to correct problems, you have held broken packages.

答案2

它说你没有安装该程序。因此你可以使用以下命令安装 nodejs:

sudo apt-get install nodejs-legacy

并使用以下命令安装 maven:

sudo apt-get install maven

相关内容