Node.js installation and configuration
1 Node. Js installation
Node.js can be downloaded from nodejs.org/zh-cn/
You can download historical versions of Node.js from nodejs.org/dist/
Note: Installing Node.js on Linux requires Python 2.6 or 2.7. Python 3.0 or later is not recommended. (Rookie tutorial)
Download and install, you can follow the rookie tutorial Node.js installation tutorial to install.
Address: www.runoob.com/nodejs/node…
2 Node.js environment configuration
When using Node.js, many installation packages will be installed. In this case, you need to consider whether the PC performance will be degraded due to occupying too much space on the system disk (disk C). Therefore, you need to change some default configurations of Node.js to ensure that PC performance will not be affected after downloading many installation packages in the future.
- Configure the path of the global module installed by NPM and the path of the cache cache
Create two folders anywhere (except the system disk). The following two folders are created according to the principle of knowing the meaning of the key name
-
Set global directory and cache directory, here are two ways
- Run the following command to open the CMD command line window:
npm config set prefix “D:\whtTools\nodejs\node_global”
npm config set cache “D:\whtTools\nodejs\node_cache”
- Modify the configuration file directly
Go to the C:\Users\ computer user name (such as myself: C:\Users\Administrator) folder, open the.npmrc file and modify it directly
-
Environment Variable Configuration
To be able to use node. js commands globally, right-click “My Computer” > Properties > Advanced System Settings > Environment Variables > System Variables > New, and set the variable value to the node_modules folder in the Node installation directory
Then change the system variable Path as follows:
The Node environment is now ready.