Home>Article>Web Front-end> Introduction to nodejs installation and configuration environment methods

Introduction to nodejs installation and configuration environment methods

青灯夜游
青灯夜游 forward
2020-08-18 10:27:43 3890browse

Introduction to nodejs installation and configuration environment methods

Using vue, installingnodejsis the basis. I will teach you my own installation steps here. [Video tutorial recommendation:nodejs tutorial]

1. Download

Download address: https://nodejs.org/en/download/
Introduction to nodejs installation and configuration environment methods

2. Installation:

1. After downloading, double-click to open:
Introduction to nodejs installation and configuration environment methods
2. Click next to start installation
Introduction to nodejs installation and configuration environment methods
3 .Select the "Accept button" and proceed to the next step
Introduction to nodejs installation and configuration environment methods
4.Select the installation path
Introduction to nodejs installation and configuration environment methods
5.Install the mode you need
Introduction to nodejs installation and configuration environment methods
6 .Start the installation install
Introduction to nodejs installation and configuration environment methods
7.Complete finish
Introduction to nodejs installation and configuration environment methods

After installation, open the terminal window R

Introduction to nodejs installation and configuration environment methods

cmd Enter; enter the command: "node -v" Check the version number

Introduction to nodejs installation and configuration environment methods

If the version number appears, it means that you already have nodejs on your computer and the installation is successful!

3. Configuration environment

NodeJS and NPM cannot be used directly after they are installed. By default, the modules installed by NPM will not be installed in the NodeJS program directory, such as the ones we installed. When we set the D drive, "D:\Program Files\nodejs", and we use npm to install a cluster module, it will appear under the default path of the C drive. Therefore, if we do not modify the module installation directory of npm, then it will default to It will be installed here in every situation. As you test and develop various projects and install more and more modules, the size of this folder will become larger and larger until it fills up your C drive. So we need to modify the npm configuration.

1. In the nodejs folder, create two folders: node_global;node_cecal

This is used to store the cache files of the installation process and the final module configuration location
Introduction to nodejs installation and configuration environment methods

2. Use the following commands to configure npm’s global module directory and cache directory to the two directories we just created

npm config set prefix "The path to the node_global file "
npm config set cache "node_cache file path"
For example: npm config set prefix "D:\Program Files\nodejs\node_global"

3 .Advanced system settings - environment variables

Add new system variables:
Fill in the variable name: NODE_PATH
Fill in the variable value: (file path)
Introduction to nodejs installation and configuration environment methods
You also need to add Modify the default path of the nodejs file in the Path variable name
Introduction to nodejs installation and configuration environment methods
Test after the modification is completed:
Enter the command: node and press Enter - then enter require('cluster')
Introduction to nodejs installation and configuration environment methods
The above content indicates that the configuration is complete

For more programming-related knowledge, please visit:Introduction to Programming! !

The above is the detailed content of Introduction to nodejs installation and configuration environment methods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete