Home  >  Article  >  Web Front-end  >  Install nodejs offline on linux

Install nodejs offline on linux

WBOY
WBOYOriginal
2023-05-12 10:34:361780browse

In many cases, we may need to install node.js offline (without access to the Internet) on a Linux system. This may occur due to network restrictions or security restrictions, etc., but it does not mean that we cannot install node.js. In this article, I will show you how to complete the process of installing node.js offline on your Linux system.

  1. Download the required files

Because we cannot use the network to download node.js, we need to download it on another machine with Internet access. We need to download the following three files:

  • node.js binary file
  • npm package manager for node.js
  • libssl-dev package

You can download the node.js binary file through the node.js official website. Be careful to choose the version that corresponds to the version of the Linux system you are running.

To download the npm package manager, you can get it on the npm official website. It should be noted that you need to download the version of the npm package manager corresponding to the node.js version.

Finally, to get the libssl-dev package, run the following command in the command line window:

sudo apt-get install libssl-dev

This package is to ensure that we can install Node.js on a Linux system.

  1. Copy the files to the offline machine

Copy the three downloaded files to the Linux server where you need to install node.js. You can use a USB drive or any other available external storage device. Copy the file to your Linux system and put it in a directory you can access, for example:

/home/user/nodejs_installer/
  1. Install node.js

First, we need to unzip and Install the node.js binary:

tar -xvf node-vxx.xx.x-linux-x64.tar.gz
cd node-vxx.xx.x-linux-x64
./configure
make
make install

Replace "xx.xx.x" here with the node.js version number you downloaded.

Once you have completed the installation of node.js, you need to install the npm package manager. You need to unzip and install the npm binary:

tar -xvf <npm*.tgz>
cd package
sudo npm install -g --unsafe-perm

After completing the process of installing npm, you need to install the libssl-dev package, which will make your node.js run smoother:

sudo apt-get install libssl-dev
  1. Test whether node.js installation is successful

After installing node.js, you should be able to use the following command to check whether you have successfully installed node.js:

node -v

This command should display the version of node.js you are running.

  1. Conclusion

Installing node.js offline on a Linux system is not more difficult than installing it online. Just follow the above steps in order. After the installation is complete, you can run your node.js application as needed.

To avoid this happening again, I strongly recommend that you ensure that your Linux server is always connected via the network. This will keep your server up to date and up to date with security patches.

The above is the detailed content of Install nodejs offline on linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn