无法在Ubuntu中使用node package manager安装包

时间:2022-05-19 06:31:07

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of name conflict with another package. Here's what the readme.debian says:

Ubuntu上的NodeJS解释器名(node)由于与另一个包的名称冲突而被重命名为NodeJS。debian说:

The upstream name for the Node.js interpreter command is "node". In Debian the interpreter command has been changed to "nodejs".

节点的上游名称。js解释器命令是“node”。在Debian中,解释器命令被更改为“nodejs”。

This was done to prevent a namespace collision: other commands use the same name in their upstreams, such as ax25-node from the "node" package.

这样做是为了防止名称空间冲突:其他命令在它们的upstreams中使用相同的名称,比如来自“node”包的ax25-node。

Scripts calling Node.js as a shell command must be changed to instead use the "nodejs" command.

脚本调用节点。作为shell命令的js必须更改为使用“nodejs”命令。

However, using nodejs mucks up installing packages using npm. Package installation fails with the following error:

但是,使用nodejs会使用npm安装包。包安装失败,错误如下:

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian

How do I make npm understand that nodejs is already installed on the system but the interpreter name is different?

如何让npm理解系统上已经安装了nodejs,但是解释器名称不同?

17 个解决方案

#1


1047  

TL;DR:

TL;博士:

sudo apt-get install nodejs-legacy

First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.

首先让我澄清一下情况。2012年夏天,Debian维护人员决定重新命名Node。js可执行文件,以防止与另一个包发生某种名称空间冲突。对于Debian技术委员会来说,这是一个非常艰难的决定,因为它打破了向后兼容。

The following is a quote from Committee resolution draft, published in Debian mailing list:

以下是在Debian邮件列表中发表的委员会决议草案:

  1. The nodejs package shall be changed to provide /usr/bin/nodejs, not /usr/bin/node. The package should declare a Breaks: relationship with any packages in Debian that reference /usr/bin/node.

    nodejs包应该更改为提供/usr/bin/nodejs,而不是/usr/bin/nodejs。包应该声明一个断点:与引用/usr/bin/ nodede的Debian中的任何包的关系。

  2. The nodejs source package shall also provide a nodejs-legacy binary package at Priority: extra that contains /usr/bin/node as a symlink to /usr/bin/nodejs. No package in the archive may depend on or recommend the nodejs-legacy package, which is provided solely for upstream
    compatibility. This package declares shall also declare a Conflicts: relationship with the node package.

    nodejs源包还应该优先提供一个node -legacy二进制包:extra包含/usr/bin/node作为/usr/bin/nodejs的符号链接归档中的任何包都不能依赖或推荐nodejs-legacy包,该包仅为上游兼容性提供。这个包还声明一个冲突:与节点包的关系。

<...>

<…>

Paragraph 2 is the actual solution for OP's issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.

第2段是OP问题的实际解决方案。OP应该尝试安装这个包,而不是手工执行symlink。这里是Debian软件包索引网站中的这个软件包的链接。

It can be installed using sudo apt-get install nodejs-legacy.

它可以使用sudo apt-get install nodejs-legacy来安装。

I have not found any information about adopting the whole thing by NPM developers, but I think npm package will be fixed on some point and nodejs-legacy become really legacy.

我还没有发现任何关于NPM开发人员采用整个东西的信息,但是我认为NPM包将会在某个点上得到修复,nodejs遗留成为真正的遗留。

#2


105  

Try linking node to nodejs. First find out where nodejs is

尝试将节点链接到nodejs。首先找出nodejs在哪里

whereis nodejs

Then soft link node to nodejs

然后是软链接节点到node . js。

ln -s [the path of nodejs] /usr/bin/node 

I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.

假设/usr/bin在执行路径中。然后,您可以通过在命令行中输入node或npm来进行测试,现在一切都应该正常工作了。

#3


41  

You can also install Nodejs using NVM or Nodejs Version Manager There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.

您还可以使用NVM或Nodejs版本管理器安装Nodejs。使用版本管理器有很多好处。其中之一就是你不必担心这个问题。


Instructions:


sudo apt-get update
sudo apt-get install build-essential libssl-dev

Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:

一旦安装了先决条件包,您就可以从项目的GitHub页面下拉nvm安装脚本。版本号可能不同,但一般来说,您可以下载并安装它,使用以下语法:

curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh

This will download the script and run it. It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.

这将下载脚本并运行它。它将把软件安装到~/.nvm的主目录子目录中。它还将向您的~/添加必要的行。配置文件使用该文件。

To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:

为了获得对nvm功能的访问,您将需要注销并再次登录,或者您可以提供~/。配置文件,使您的当前会话知道更改:

source ~/.profile

Now that you have nvm installed, you can install isolated Node.js versions.

现在已经安装了nvm,可以安装独立节点了。js版本。

To find out the versions of Node.js that are available for installation, you can type:

查找节点的版本。可供安装的js,可输入:

nvm ls-remote
. . .

v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.14

As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:

如您所见,本文撰写时的最新版本是v0.11.14。你可以通过输入:

nvm install 0.11.14

Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:

通常,nvm将切换到使用最近安装的版本。你可以明确地告诉nvm使用我们刚下载的版本,输入:

nvm use 0.11.14

When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:

当你安装节点。使用nvm,可执行文件称为节点。您可以通过输入以下命令查看shell当前使用的版本:

node -v

The comeplete tutorial can be found here

complete教程可以在这里找到

#4


14  

  1. Install nvm first using:

    安装nvm首先使用:

    curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
    
  2. Run command

    运行命令

    source ~/.profile
    
  3. Now run this and this will show will all installed or other versions of packages:

    现在运行这个,这个将会显示所有安装或其他版本的软件包:

    nvm ls-remote
    
  4. Installed packages will be in green. Install whatever version you want:

    已安装的软件包将是绿色的。安装任何你想要的版本:

    nvm install 6.0.0
    
  5. Check where is not installed:

    检查未安装的位置:

    which node
    
  6. Check current version:

    检查当前版本:

    node -v
    
    n=$(which node);
    n=${n%/bin/node}; 
    chmod -R 755 $n/bin/*; 
    sudo cp -r $n/{bin,lib,share} /usr/local
    

#5


11  

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs

sudo apt-get install nodejs-legacy
source ~/.profile

Combined the accepted answer with source ~/.profile from the comment that has been folded and some clean up commands before. Most likely you will also need to sudo apt-get install npm after.

将接受的答案与来源~/结合起来。来自已折叠的注释的概要文件和一些以前清理过的命令。最有可能的是,您还需要sudo apt-get install npm after。

#6


9  

Here's another approach I use since I like n for easy switching between node versions.

这是我使用的另一种方法,因为我喜欢在节点版本之间轻松切换n。

On a new Ubuntu system, first install the 'system' node:

在一个新的Ubuntu系统中,首先安装“系统”节点:

curl -sL https://deb.nodesource.com/setup | sudo bash -

Then install n module globally:

然后全局安装n模块:

npm install -g n

Since the system node was installed first (above), the alternatives system can be used to cleanly point to the node provided by n. First make sure the alternatives system has nothing for node:

由于系统节点是先安装的(以上),可使用备选系统将节点清晰地指向n提供的节点。

update-alternatives --remove-all node

Then add the node provided by n:

然后添加n提供的节点:

update-alternatives --install /usr/bin/node node /usr/local/bin/node 1

Next add node provided by the system (the one that was installed with curl):

接下来添加系统提供的节点(使用curl安装的节点):

update-alternatives --install /usr/bin/node node /usr/bin/nodejs 2

Now select the node provided by n using the interactive menu (select /usr/local/bin/node from the menu presented by the following command):

现在使用交互式菜单选择n提供的节点(从下面的命令提供的菜单中选择/usr/local/bin/node):

update-alternatives --config node

Finally, since /usr/local/bin usually has a higher precedence in PATH than /usr/bin, the following alias must be created (enter in your .bashrc or .zshrc) if the alternatives system node is to be effective; otherwise the node installed with n in /usr/local/bin takes always precedence:

最后,由于/usr/local/bin在路径上的优先级通常高于/usr/bin,如果要使替代系统节点有效,则必须创建以下别名(在.bashrc或.zshrc中输入);否则,在/usr/local/bin中安装n的节点总是优先:

alias node='/usr/bin/node'

Now you can easily switch between node versions with n <desired node version number>.

现在,您可以轻松地使用n <期望的节点版本号> 在节点版本之间进行切换。

#7


9  

for me problem was solved by,

对我来说,问题通过,

sudo apt-get remove node
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
alias node=nodejs
rm -r /usr/local/lib/python2.7/dist-packages/localstack/node_modules
npm install -g npm@latest || sudo npm install -g npm@latest

#8


8  

On Linux Mint 17, I tried both solutions (creating a symlink or using the nodejs-legacy package) without success.

在Linux Mint 17上,我尝试了两种解决方案(创建一个符号链接或使用nodejs-legacy包),但都没有成功。

The only thing that finally worked for me was using the ppa from Chris Lea:

唯一对我有用的是克里斯·里亚的ppa:

sudo apt-get purge node-*
sudo apt-get autoremove 
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

This installed node version 10.37 and npm 1.4.28. After that, I could install packages globally.

这个安装的节点版本是10.37和npm 1.4.28。之后,我可以在全局上安装包。

#9


7  

As other folks already mention, I will suggest not to use "sudo apt-get" to install node or any development library. You can download required version from https://nodejs.org/dist/v6.9.2/ and setup you own environment.

正如其他人已经提到的,我将建议不要使用“sudo apt-get”来安装node或任何开发库。您可以从https://nodejs.org/dist/v6.9.2/以及您自己的环境中下载所需的版本。

I will recommend tools like nvm and n, to manage you node version. It is very convenient to switch and work with these modules. https://github.com/creationix/nvm https://github.com/tj/n

我将推荐nvm和n这样的工具来管理节点版本。切换和使用这些模块非常方便。https://github.com/creationix/nvm https://github.com/tj/n

Or write basic bash to download zip/tar, extract move folder and create a soft link. Whenever you need to update, just point the old soft link to new downloaded version. Like I have created for my own, you can refer: https://github.com/deepakshrma/NodeJs-4.0-Reference-Guide/blob/master/nodejs-installer.sh

或者编写基本bash来下载zip/tar、提取move文件夹并创建一个软链接。每当需要更新时,只需将旧的软链接指向新下载的版本。就像我为自己创建的一样,您可以参考https://github.com/deepakshrma/nodejs -4.0- reference guide /blob/master/nodejs-installer.sh

#Go to home
cd ~
#run command
#New Script
wget https://raw.githubusercontent.com/deepakshrma/NodeJs-4.0-Reference-Guide/master/nodejs-installer.sh 
bash nodejs-installer.sh -v lts
#here -v or --version can be sepecific to 0.10.37 or it could be latest/lts 
#Examples
bash nodejs-installer.sh -v lts
bash nodejs-installer.sh -v latest
bash nodejs-installer.sh -v 4.4.2

#10


4  

Simple solution from here

简单的解决方案从这里

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash --
sudo apt-get install nodejs

You can specify version by changing setup_x.x value, for example to setup_5.x

您可以通过更改setup_x来指定版本。x值,例如setup_5.x

#11


3  

Uninstall whatever node version you have

卸载您拥有的任何节点版本。

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs

install nvm (Node Version Manager) https://github.com/creationix/nvm

安装nvm(节点版本管理器)https://github.com/creationix/nvm

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

Now you can install whatever version of node you want and switch between the versions.

现在,您可以安装任何版本的节点,并在版本之间进行切换。

#12


3  

Your System is not able to detect the path node js binary.

您的系统无法检测路径节点js二进制文件。

1.which node

1。哪个节点

2.Then soft link node to nodejs

2。然后是软链接节点到node . js。

ln -s [the path of nodejs] /usr/bin/node 

I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.

假设/usr/bin在执行路径中。然后,您可以通过在命令行中输入node或npm来进行测试,现在一切都应该正常工作了。

#13


2  

I fixed it unlinking /usr/sbin/node (which is linked to ax25-node package), then I have create a link to nodejs using this on command line

我修复了它的unlink /usr/sbin/node(链接到ax25-node包),然后在命令行中创建了一个指向nodejs的链接

sudo ln -s /usr/bin/nodejs /usr/bin/node

Because package such as karma doesn't work with nodejs name, however changing the first line of karma script from node to nodejs, but I prefer resolve this issue once and for all

因为像karma这样的包不使用node . js的名称,但是将第一行的karma脚本从node更改为nodejs,但是我更喜欢一次性解决这个问题。

#14


1  

For me the fix was removing the node* packages and also the npm packages.

对我来说,解决方案是删除节点*包和npm包。

Then a fresh install as:

然后重新安装为:

sudo apt-get install autoclean
sudo apt-get install nodejs-legacy
npm install

#15


0  

you can create a link ln -s nodejs node in /usr/bin hope this solves your problem.

您可以在/usr/bin中创建一个link ln -s nodejs节点,希望这能解决您的问题。

#16


0  

Problem is not in installer
replace nodejs with node or change the path from /usr/bin/nodejs to /usr/bin/node

问题不在于安装程序用node替换nodejs,或者将路径从/usr/bin/nodejs更改为/usr/bin/node

#17


0  

This is the your node is not properly install, first you need to uninstall the node then install again. To install the node this may help you http://array151.com/blog/nodejs-tutorial-and-set-up/

这是您的节点没有正确安装,首先需要卸载节点,然后再次安装。要安装节点,可以使用http://array151.com/blog/nodejs-tutorial-and-set-up/

after that you can install the packages easily. To install the packages this may help you

之后,您可以轻松地安装包。要安装这些包,这可能会对您有所帮助

http://array151.com/blog/npm-node-package-manager/

http://array151.com/blog/npm-node-package-manager/

#1


1047  

TL;DR:

TL;博士:

sudo apt-get install nodejs-legacy

First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.

首先让我澄清一下情况。2012年夏天,Debian维护人员决定重新命名Node。js可执行文件,以防止与另一个包发生某种名称空间冲突。对于Debian技术委员会来说,这是一个非常艰难的决定,因为它打破了向后兼容。

The following is a quote from Committee resolution draft, published in Debian mailing list:

以下是在Debian邮件列表中发表的委员会决议草案:

  1. The nodejs package shall be changed to provide /usr/bin/nodejs, not /usr/bin/node. The package should declare a Breaks: relationship with any packages in Debian that reference /usr/bin/node.

    nodejs包应该更改为提供/usr/bin/nodejs,而不是/usr/bin/nodejs。包应该声明一个断点:与引用/usr/bin/ nodede的Debian中的任何包的关系。

  2. The nodejs source package shall also provide a nodejs-legacy binary package at Priority: extra that contains /usr/bin/node as a symlink to /usr/bin/nodejs. No package in the archive may depend on or recommend the nodejs-legacy package, which is provided solely for upstream
    compatibility. This package declares shall also declare a Conflicts: relationship with the node package.

    nodejs源包还应该优先提供一个node -legacy二进制包:extra包含/usr/bin/node作为/usr/bin/nodejs的符号链接归档中的任何包都不能依赖或推荐nodejs-legacy包,该包仅为上游兼容性提供。这个包还声明一个冲突:与节点包的关系。

<...>

<…>

Paragraph 2 is the actual solution for OP's issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.

第2段是OP问题的实际解决方案。OP应该尝试安装这个包,而不是手工执行symlink。这里是Debian软件包索引网站中的这个软件包的链接。

It can be installed using sudo apt-get install nodejs-legacy.

它可以使用sudo apt-get install nodejs-legacy来安装。

I have not found any information about adopting the whole thing by NPM developers, but I think npm package will be fixed on some point and nodejs-legacy become really legacy.

我还没有发现任何关于NPM开发人员采用整个东西的信息,但是我认为NPM包将会在某个点上得到修复,nodejs遗留成为真正的遗留。

#2


105  

Try linking node to nodejs. First find out where nodejs is

尝试将节点链接到nodejs。首先找出nodejs在哪里

whereis nodejs

Then soft link node to nodejs

然后是软链接节点到node . js。

ln -s [the path of nodejs] /usr/bin/node 

I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.

假设/usr/bin在执行路径中。然后,您可以通过在命令行中输入node或npm来进行测试,现在一切都应该正常工作了。

#3


41  

You can also install Nodejs using NVM or Nodejs Version Manager There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.

您还可以使用NVM或Nodejs版本管理器安装Nodejs。使用版本管理器有很多好处。其中之一就是你不必担心这个问题。


Instructions:


sudo apt-get update
sudo apt-get install build-essential libssl-dev

Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:

一旦安装了先决条件包,您就可以从项目的GitHub页面下拉nvm安装脚本。版本号可能不同,但一般来说,您可以下载并安装它,使用以下语法:

curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh

This will download the script and run it. It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.

这将下载脚本并运行它。它将把软件安装到~/.nvm的主目录子目录中。它还将向您的~/添加必要的行。配置文件使用该文件。

To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:

为了获得对nvm功能的访问,您将需要注销并再次登录,或者您可以提供~/。配置文件,使您的当前会话知道更改:

source ~/.profile

Now that you have nvm installed, you can install isolated Node.js versions.

现在已经安装了nvm,可以安装独立节点了。js版本。

To find out the versions of Node.js that are available for installation, you can type:

查找节点的版本。可供安装的js,可输入:

nvm ls-remote
. . .

v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.14

As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:

如您所见,本文撰写时的最新版本是v0.11.14。你可以通过输入:

nvm install 0.11.14

Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:

通常,nvm将切换到使用最近安装的版本。你可以明确地告诉nvm使用我们刚下载的版本,输入:

nvm use 0.11.14

When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:

当你安装节点。使用nvm,可执行文件称为节点。您可以通过输入以下命令查看shell当前使用的版本:

node -v

The comeplete tutorial can be found here

complete教程可以在这里找到

#4


14  

  1. Install nvm first using:

    安装nvm首先使用:

    curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
    
  2. Run command

    运行命令

    source ~/.profile
    
  3. Now run this and this will show will all installed or other versions of packages:

    现在运行这个,这个将会显示所有安装或其他版本的软件包:

    nvm ls-remote
    
  4. Installed packages will be in green. Install whatever version you want:

    已安装的软件包将是绿色的。安装任何你想要的版本:

    nvm install 6.0.0
    
  5. Check where is not installed:

    检查未安装的位置:

    which node
    
  6. Check current version:

    检查当前版本:

    node -v
    
    n=$(which node);
    n=${n%/bin/node}; 
    chmod -R 755 $n/bin/*; 
    sudo cp -r $n/{bin,lib,share} /usr/local
    

#5


11  

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs

sudo apt-get install nodejs-legacy
source ~/.profile

Combined the accepted answer with source ~/.profile from the comment that has been folded and some clean up commands before. Most likely you will also need to sudo apt-get install npm after.

将接受的答案与来源~/结合起来。来自已折叠的注释的概要文件和一些以前清理过的命令。最有可能的是,您还需要sudo apt-get install npm after。

#6


9  

Here's another approach I use since I like n for easy switching between node versions.

这是我使用的另一种方法,因为我喜欢在节点版本之间轻松切换n。

On a new Ubuntu system, first install the 'system' node:

在一个新的Ubuntu系统中,首先安装“系统”节点:

curl -sL https://deb.nodesource.com/setup | sudo bash -

Then install n module globally:

然后全局安装n模块:

npm install -g n

Since the system node was installed first (above), the alternatives system can be used to cleanly point to the node provided by n. First make sure the alternatives system has nothing for node:

由于系统节点是先安装的(以上),可使用备选系统将节点清晰地指向n提供的节点。

update-alternatives --remove-all node

Then add the node provided by n:

然后添加n提供的节点:

update-alternatives --install /usr/bin/node node /usr/local/bin/node 1

Next add node provided by the system (the one that was installed with curl):

接下来添加系统提供的节点(使用curl安装的节点):

update-alternatives --install /usr/bin/node node /usr/bin/nodejs 2

Now select the node provided by n using the interactive menu (select /usr/local/bin/node from the menu presented by the following command):

现在使用交互式菜单选择n提供的节点(从下面的命令提供的菜单中选择/usr/local/bin/node):

update-alternatives --config node

Finally, since /usr/local/bin usually has a higher precedence in PATH than /usr/bin, the following alias must be created (enter in your .bashrc or .zshrc) if the alternatives system node is to be effective; otherwise the node installed with n in /usr/local/bin takes always precedence:

最后,由于/usr/local/bin在路径上的优先级通常高于/usr/bin,如果要使替代系统节点有效,则必须创建以下别名(在.bashrc或.zshrc中输入);否则,在/usr/local/bin中安装n的节点总是优先:

alias node='/usr/bin/node'

Now you can easily switch between node versions with n <desired node version number>.

现在,您可以轻松地使用n <期望的节点版本号> 在节点版本之间进行切换。

#7


9  

for me problem was solved by,

对我来说,问题通过,

sudo apt-get remove node
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
alias node=nodejs
rm -r /usr/local/lib/python2.7/dist-packages/localstack/node_modules
npm install -g npm@latest || sudo npm install -g npm@latest

#8


8  

On Linux Mint 17, I tried both solutions (creating a symlink or using the nodejs-legacy package) without success.

在Linux Mint 17上,我尝试了两种解决方案(创建一个符号链接或使用nodejs-legacy包),但都没有成功。

The only thing that finally worked for me was using the ppa from Chris Lea:

唯一对我有用的是克里斯·里亚的ppa:

sudo apt-get purge node-*
sudo apt-get autoremove 
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

This installed node version 10.37 and npm 1.4.28. After that, I could install packages globally.

这个安装的节点版本是10.37和npm 1.4.28。之后,我可以在全局上安装包。

#9


7  

As other folks already mention, I will suggest not to use "sudo apt-get" to install node or any development library. You can download required version from https://nodejs.org/dist/v6.9.2/ and setup you own environment.

正如其他人已经提到的,我将建议不要使用“sudo apt-get”来安装node或任何开发库。您可以从https://nodejs.org/dist/v6.9.2/以及您自己的环境中下载所需的版本。

I will recommend tools like nvm and n, to manage you node version. It is very convenient to switch and work with these modules. https://github.com/creationix/nvm https://github.com/tj/n

我将推荐nvm和n这样的工具来管理节点版本。切换和使用这些模块非常方便。https://github.com/creationix/nvm https://github.com/tj/n

Or write basic bash to download zip/tar, extract move folder and create a soft link. Whenever you need to update, just point the old soft link to new downloaded version. Like I have created for my own, you can refer: https://github.com/deepakshrma/NodeJs-4.0-Reference-Guide/blob/master/nodejs-installer.sh

或者编写基本bash来下载zip/tar、提取move文件夹并创建一个软链接。每当需要更新时,只需将旧的软链接指向新下载的版本。就像我为自己创建的一样,您可以参考https://github.com/deepakshrma/nodejs -4.0- reference guide /blob/master/nodejs-installer.sh

#Go to home
cd ~
#run command
#New Script
wget https://raw.githubusercontent.com/deepakshrma/NodeJs-4.0-Reference-Guide/master/nodejs-installer.sh 
bash nodejs-installer.sh -v lts
#here -v or --version can be sepecific to 0.10.37 or it could be latest/lts 
#Examples
bash nodejs-installer.sh -v lts
bash nodejs-installer.sh -v latest
bash nodejs-installer.sh -v 4.4.2

#10


4  

Simple solution from here

简单的解决方案从这里

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash --
sudo apt-get install nodejs

You can specify version by changing setup_x.x value, for example to setup_5.x

您可以通过更改setup_x来指定版本。x值,例如setup_5.x

#11


3  

Uninstall whatever node version you have

卸载您拥有的任何节点版本。

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs

install nvm (Node Version Manager) https://github.com/creationix/nvm

安装nvm(节点版本管理器)https://github.com/creationix/nvm

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

Now you can install whatever version of node you want and switch between the versions.

现在,您可以安装任何版本的节点,并在版本之间进行切换。

#12


3  

Your System is not able to detect the path node js binary.

您的系统无法检测路径节点js二进制文件。

1.which node

1。哪个节点

2.Then soft link node to nodejs

2。然后是软链接节点到node . js。

ln -s [the path of nodejs] /usr/bin/node 

I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.

假设/usr/bin在执行路径中。然后,您可以通过在命令行中输入node或npm来进行测试,现在一切都应该正常工作了。

#13


2  

I fixed it unlinking /usr/sbin/node (which is linked to ax25-node package), then I have create a link to nodejs using this on command line

我修复了它的unlink /usr/sbin/node(链接到ax25-node包),然后在命令行中创建了一个指向nodejs的链接

sudo ln -s /usr/bin/nodejs /usr/bin/node

Because package such as karma doesn't work with nodejs name, however changing the first line of karma script from node to nodejs, but I prefer resolve this issue once and for all

因为像karma这样的包不使用node . js的名称,但是将第一行的karma脚本从node更改为nodejs,但是我更喜欢一次性解决这个问题。

#14


1  

For me the fix was removing the node* packages and also the npm packages.

对我来说,解决方案是删除节点*包和npm包。

Then a fresh install as:

然后重新安装为:

sudo apt-get install autoclean
sudo apt-get install nodejs-legacy
npm install

#15


0  

you can create a link ln -s nodejs node in /usr/bin hope this solves your problem.

您可以在/usr/bin中创建一个link ln -s nodejs节点,希望这能解决您的问题。

#16


0  

Problem is not in installer
replace nodejs with node or change the path from /usr/bin/nodejs to /usr/bin/node

问题不在于安装程序用node替换nodejs,或者将路径从/usr/bin/nodejs更改为/usr/bin/node

#17


0  

This is the your node is not properly install, first you need to uninstall the node then install again. To install the node this may help you http://array151.com/blog/nodejs-tutorial-and-set-up/

这是您的节点没有正确安装,首先需要卸载节点,然后再次安装。要安装节点,可以使用http://array151.com/blog/nodejs-tutorial-and-set-up/

after that you can install the packages easily. To install the packages this may help you

之后,您可以轻松地安装包。要安装这些包,这可能会对您有所帮助

http://array151.com/blog/npm-node-package-manager/

http://array151.com/blog/npm-node-package-manager/