Home > Web Front-end > JS Tutorial > Introduction to the steps to build a node.js environment on a linux server

Introduction to the steps to build a node.js environment on a linux server

不言
Release: 2019-03-11 17:16:47
forward
3535 people have browsed it

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
Copy after login

After downloading, unzip it

tar xvJf node-v10.15.3-linux-x64.tar.xz
Copy after login

Unzip the node Move the .js directory to the /usr/local directory

mv node-v10.15.3-linux-x64 /usr/local/node-v10
Copy after login

Configure the node soft connection to the /bin directory

ln -s /usr/local/node-v10/bin/node /bin/node
Copy after login

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
Copy after login

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
Copy after login

Effective environment variables

source /etc/profile
Copy after login

Use npm
Install the process management module forever through npm

npm install forever -g
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template