nodejs download installation configuration environment


1. Download
Download link: https://nodejs.org/en/download/


After the download is complete, double-click the installation package to start the installation, and keep clicking next. I set the installation path to D:\Program Files\nodejs\

After installation, open the terminal window+R
cmd and press Enter; enter the command: "node -v" to view the version number

The version number appears, indicating that nodejs is already on your computer and the installation is successful!

 

2. Configuration environment

Because when you execute commands such as npm install webpack -g to install globally, the module will be installed by default in npm and npm_cache under the C:\Users\username\AppData\Roaming path, which is inconvenient to manage and takes up C drive space

Under the nodejs folder, create two folders: node_global; node_cache
This is used to store the cache files for the installation process and the final module configuration location


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 "D:\Program Files\nodejs\node_global"
npm config set cache "D:\Program Files\nodejs\node_cache"

After execution, configure environment variables as follows:

"Environmental Variables" -> "System Variables": Create a new variable named "NODE_PATH" with a value of "D:\Program Files\nodejs\node_global\node_modules".
"Environment Variables" -> "User Variables": Edit the Path in the user variables and append: "D:\Program Files\nodejs\node_global".

Guess you like

Origin blog.csdn.net/lw112190/article/details/108052594
Recommended