"node.js" environment variables refer to objects with specific names in the "node.js" running environment, that is, parameters of the running environment; environment variables are equivalent to some settings set for the system or user applications. Parameters, after installing node, you can add "G:\Node.js" to the system environment variable path.
The operating environment of this article: Windows 10 system, nodejs version 16, Dell G3 computer.
An environment variable is an object with a specific name in the operating system, which contains one or more applications Information that will be used by the program.
Popularly understood as: some specified folder paths, the purpose is to find the desired files and folders more quickly and conveniently.
Environment variables are equivalent to some parameters set to the system or user applications, such as path, which tells the system when the system is asked to run a program without telling it the full path of the program. , the system should not only search for this program in the current directory, but also go to the path specified in path.
nodejs download and installation
Official website to download the corresponding system installation package
Be careful to modify the installation directory when installing. It is recommended to place it in a non-C drive directory. Just install it by default;
After the installation is complete, start the command line tool, enter node -vnpm -v to check the installation version, and if the version information is prompted, the installation is successful.
Environment configuration
Description: The environment configuration here mainly configures the path where the global module installed by npm is located, and the cache The cache path needs to be configured because when you execute an installation statement similar to: npm install module name [-g] in the future, the installed module will be installed to [C:\Users\username\AppData\Roaming\npm 】path, occupying C drive space.
This article installs nodejs in the D:\soft\nodejs directory. The following operations can be adjusted according to the actual installation directory.
In the installation directory, such as D:\soft\nodejs, create two new folders node_global (global package storage directory) and node_cache (cache directory);
Open the command line tool and perform the following two operations: npm config set prefix "D:\soft\nodejs\node_global" npm config set cache "D:\soft\nodejs\node_cache";
Configure environment variables:
Open System Properties-Advanced-Environment Variables, create a new variable name in the system variables: NODE_PATH, variable value: D:\soft\ nodejs\node_global\node_modules;
Edit the path of the user variable and change the default APPData/Roaming\npm under the C drive to D:\soft\nodejs\node_global;
Save it.
## Recommended learning: "nodejs video tutorial"
The above is the detailed content of What do node.js environment variables mean?. For more information, please follow other related articles on the PHP Chinese website!