In general development, we will directly reference the jdk package by configuring JAVA_HOME instead of reinstalling a jdk.exe. So can nodejs be installed in the same way?
Of course, otherwise I wouldn’t be writing this blog. Okay, enough nonsense, let’s go to the tutorial
First download the non-installation version of nodejs. Of course, you can also install it first, and then copy the installed Nodejs folder. You can always use this folder in the future and configure the environment variables. , instead of reinstalling it every time
First, configure NODE_PATH. Note here that NODE_PATH needs to be configured with two values
1. Configure the physical path of the Nodejs folder
2. Configure to the folder Nodejs\node_global\node_modules
Configure NODE_PATH: D:\myEvn\tools\Nodejs\node_global\node_modules;D:\myEvn\tools\Nodejs
Then configure Path, two items need to be configured here as well
1. Configure the physical path of the Nodejs folder like NODE_PATH
2. Configure Nodejs global variable address
Configure Path: D:\myEvn\tools\Nodejs;D:\myEvn\tools\Nodejs\node_global
Configuring Path, we may take it for granted like Configure %JAVA_HOME%\bin like configuring JAVA. In fact, this is one of the pitfalls. What really works are the two addresses configured in the path environment variable (there is no way to configure variables like NODE_HOME, because there is no such thing as \bin a folder), what is executed in the command is the XX.cmd file under the two paths configured by this path, and then the downloaded resources are placed in NODE_PATH
Modify the global variables and cache address, open Command prompt (win+r and enter cmd)
Modify global variables, enter
npm config set prefix “D:\myEvn\tools\Nodejs\node_global”
to modify the cache storage location, enter
npm config set cache “D:\myEvn\tools\Nodejs\node_cache”
to view the global variable address
View the global variable address, enter
npm config get prefix
Result:
View cache address, enter
npm config get cache
Result:
Verify installation
npm -v
OK, the configuration here completes all the configuration of Nodejs
The above is the detailed content of Node.js non-installation configuration method. For more information, please follow other related articles on the PHP Chinese website!