Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to install Nodejs in Linux

Shulou Source: shulou.com Published: 2022-06-01 17:33:09 11月15日 Update

How to install Nodejs in Linux, for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

First of all, go to the official website to download the code, here we must pay attention to the installation of two kinds, one is the Source Code source code, the other is the compiled file. I just operate the compiled files in accordance with the installation of the online source code, resulting in a pit for a long time.

Pay attention to what files you download! The corresponding installation methods are different.

(1) compiled documents

To put it simply, after decompression, node and npm already exist in the bin folder. If you enter the corresponding file and execute the command line, there is no problem at all, but it is not global, so set this to global.

Cd node-v0.10.28-linux-x64/bin

Ls

. / node-v

This is all right. You can choose the name of the node folder exactly where you want to put it. Then set the global:

Ln-s / home/kun/mysofltware/node-v0.10.28-linux-x64/bin/node / usr/local/bin/node

Ln-s / home/kun/mysofltware/node-v0.10.28-linux-x64/bin/npm / usr/local/bin/npm

You put this path here / home/kun/mysofltware/ on your own, and you unzip the node file wherever you go.

(2) compiling through source code

The file you download in this way is Source code, which is more troublesome.

# tar xvf node-v0.10.28.tar.gz

# cd node-v0.10.28

# . / configure

# make

# make install

# cp / usr/local/bin/node / usr/sbin/

View the currently installed version of Node

# node-v

V0.10.28

(3) apt-get

Another is the apt-get method of shell prompt, which is not highly recommended.

Sudo apt-get install nodejs

Sudo apt-get install npm

This is the answer to the question about how to install Nodejs in Linux. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.

Tags: File that is way question compile global source code folder more help answer different proper easy easy code content name command boy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Microsoft OPPO Reno Docker Huawei