Home >Web Front-end >Front-end Q&A >Linux installation nodejs v8
Linux is a very popular operating system, especially on the server side. Node.js is a runtime environment that allows JavaScript code to run on the server side. In this article, we will discuss how to install the v8 version of Node.js on a Linux system.
Before installing Node.js, we need to ensure that our system has been updated to the latest version. The following commands can be used to update the package list and package library:
sudo apt-get update sudo apt-get upgrade
First we need to add the official source of Node.js to our In the system:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
After adding the source, execute the following command to install Node.js:
sudo apt-get install -y nodejs
After completing the installation, we can use the following command to verify that we successfully installed Node.js:
node -v
If the installation was successful, we should see our Node .js version number.
NPM is the package manager for Node.js. If we want to install various Node.js packages, we need to install NPM. NPM can be installed using the following command:
sudo apt-get install npm
After the installation is complete, we should verify whether we have successfully installed NPM using the following command:
npm -v
This should output the npm version number we installed.
We can use the following command to configure NPM to change its default location to where we want it:
npm config set prefix ~/npm
After completing the changes, we can use the following command to verify that we successfully changed the default location of NPM:
npm config get prefix
Now, we have successfully installed Node.js and NPM and can install the global packages we need. For example, if you want to install gulp:
npm install -g gulp
After the installation is complete, we can use the following command to verify whether we successfully installed the global package:
gulp -v
This should output the version number of gulp we installed.
Summary
In this article, we discussed how to install the v8 version of Node.js on a Linux system. First, we updated the system packages and then added the official source of Node.js. We then installed Node.js and NPM and configured the default location of NPM. Finally, we installed the global packages and verified their installation.
The above is the detailed content of Linux installation nodejs v8. For more information, please follow other related articles on the PHP Chinese website!