Under normal circumstances, we installed Node.js
environment, the program will automatically NPM
route the global module settings in the system tray (usually the C
lower plate), we do not recommend global path settings in the system tray in the project development phase, it will not only affect your PC's performance, but also very safe. You can set the default download path of the global directory with the following command:
Enter the command, view the current configuration:
npm config ls
The result:
The first time you use NPM
the installation package, it will only be seen in the configuration prefix
option is the NPM
default global installation directory. However, if multi-use NPM
installation package, we would see cache
and prefix
two paths, as shown below:
The first step:
Create two folders in the directory to be changed, namely: node_global_modules
and node_cache
, the effect is as:
Step two:
Open a command prompt, execute the following two commands:
npm config set prefix "D:\dev\nodejs\node_modules\npm\node_global_modules"
npm config set cache "D:\dev\nodejs\node_modules\npm\node_cache"
After successful execution, you can npm config ls
view the result of the configuration command, as shown in FIG effect:
Step:
After verifying successful configuration, you need to configure the environment variables. In the environment variables, a new system variable, the variable name: NODE_HOME
variable values: D:\dev\nodejs
results shown in Figure:
the Path
variable names, the new variable values:
%NODE_HOME%
%NOED_HOME%\node_modules
%NODE_HOME%\node_modules\npm\node_global_modules\
Results shown in Figure:
After saving, you can re-execute the command to install the global view NPM
dependencies in the global default installation directory is configured directory for us, if successfully downloaded to the directory after setting successfully modified the global default installation path.