This article brings you an introduction to the steps to build a node.js environment on a Linux server. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. Install node.js environment
node.js is JavaScript running on the server, a platform based on the Chrome JavaScript V8 engine.
Download and install node.js
Download the latest stable version v10.15.3 locally (this is the latest stable version when the article is currently published)
wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
After downloading, unzip it
tar xvJf node-v10.15.3-linux-x64.tar.xz
Unzip the node Move the .js directory to the /usr/local directory
mv node-v10.15.3-linux-x64 /usr/local/node-v10
Configure the node soft connection to the /bin directory
ln -s /usr/local/node-v10/bin/node /bin/node
2. Configure and use npm
Configuration nm
npm is the package management and distribution tool for Node.js. It allows Node.js developers to share code and common code snippets more easily
The compressed package for downloading node already contains npm, we only need to soft link it to the bin directory
ln -s /usr/local/node-v10/bin/npm /bin/npm
Configure variable environment
Add the /usr/local/node-v10/bin directory to the $PATH environment variable to easily use third-party tools installed globally through npm
echo 'export PATH=/usr/local/node-v10/bin:$PATH' >> /etc/profile
Effective environment variables
source /etc/profile
Use npm
Install the process management module forever through npm
npm install forever -g
Complete the environment setup
Congratulations! You have successfully set up the node.js environment
The above is the detailed content of Introduction to the steps to build a node.js environment on a linux server. For more information, please follow other related articles on the PHP Chinese website!