With the continuous development of front-end technology, Node.js has become one of the most popular server-side development languages. As a server operating system, Linux is also essential in the process of using Node.js. In this article, we will introduce in detail how to install and configure Node.js on Linux.
1. Environment preparation
Before installing Node.js, we need to prepare the following conditions:
2. Install Node.js
$sudo apt-get install nodejs
If you need to upgrade, you can use the following command:
$sudo apt-get install npm
$sudo npm install n –g
$sudo n stable
$curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
After the installation is complete, use the following command to install Node.js:
$nvm install 6.2.2
3. Configure Node.js
$npm config set registry https://registry.npm.taobao.org
$nvm which 6.2.2
If you want to add it to the environment variables, you can add it using the following command:
$echo "export PATH=$PATH:/usr/local/bin" >> ~/.bashrc
$source ~/.bashrc
$mkdir ~/.npm-packages
$echo "prefix=$HOME/.npm-packages" >> ~/.npmrc
$echo "NPM_PACKAGES=$HOME/.npm-packages" >> ~/.bashrc
$echo "export PATH=$PATH:$NPM_PACKAGES/bin" >> ~/.bashrc
$source ~/.bashrc
4. Summary
This article introduces the process of installing and configuring Node.js on a Linux system. When using Node.js for server-side development, a stable and efficient operating system provides great convenience for our development work. Through the introduction of this article, I believe that everyone has a certain understanding and understanding of installing Node.js on Linux.
The above is the detailed content of How to install and configure Node.js on Linux. For more information, please follow other related articles on the PHP Chinese website!