Home >Web Front-end >Front-end Q&A >Install the specified version of nodejs
Node.js is a very popular JavaScript runtime environment that provides a convenient way to run JavaScript code on the server. Node.js can only be used after the corresponding version is installed.
This article will provide a simple method to install a specified version of Node.js.
Step one: Obtain the target version of Node.js
After knowing the required Node.js version number, visit the Node.js official website and download the version of Node.js from the download page installation files. Select the corresponding compressed package according to your operating system, for example: linux-x64.tar.gz. You can also find other versions here: https://nodejs.org/dist/
Step 2: Unzip Node.js
Extract the downloaded compressed package to the directory of your choice , use the following command:
tar -xvf node-vx.x.x-linux-x64.tar.gz
In this command, x.x.x represents the Node.js version number you downloaded, and linux-x64 represents that your operating system is Linux and is 64-bit. If your operating system is different, you will need to change the file name.
Step 3: Install Node.js
Open the terminal and enter the unzipped folder:
cd node-vx.x.x-linux-x64
Then copy Node.js to /usr/local/bin Directory:
sudo cp -R * /usr/local/bin/
This recursive copy command will copy Node.js and all related files to the /usr/local/bin directory.
Step 4: Check the Node.js version
Enter the following command in the terminal to check the version:
node -v
If you see the version number you need, indicate Node. js has been successfully installed.
Now you can use your desired version of Node.js in your project. If you need to change your Node.js version, just repeat the above steps and copy the desired version to the /usr/local/bin directory.
Summary
Installing a specified version of Node.js does not require much technical skill. If you understand the above steps, you can easily install and use the Node.js version you need. Many applications require a specific version of Node.js, so this is a must-have skill.
The above is the detailed content of Install the specified version of nodejs. For more information, please follow other related articles on the PHP Chinese website!