Initial entry, from downloading Node.js to modifying the npm global installation path

Chinese path is not allowed in the following installation steps, not allowed, not allowed! ! !

1. Download Node.js

1. Enter http://nodejs.cn/ in the address bar of the browser to enter the Chinese website of node.js, or enter the Chinese website of Node in the search box and click to enter.
2. Click the download button.
3. As shown in the figure below: (Choose the type that matches your own computer, the red arrow part is the respondent's own computer type)
4. After downloading, the browser will remind you in the lower left corner of "This type of file may harm your computer. Do you still want to keep...? Click Keep." As shown below:Insert picture description here
5. In installing node.js, just click next (but remember to change the default storage path, under normal circumstances, we install the Node.js environment, the program will automatically set the path of the NPM global module in the system disk (usually C Disk), we do not recommend setting the global path in the system disk during the project development phase, which will not only affect the performance of the computer, but also is very unsafe. It is recommended to install in the root directory of the D drive, not the C drive, if you install it in the C drive Reinstall the system in the future will be lost).

Two, start to modify the npm global installation path

1. First enter the window + r command on the page, then enter the cmd command and click OK to run the "Command Prompt" window.
2. Enter the command to view the current configuration:
npm config ls
If it is the first time to use the NPM installation package, you will only see the prefix option in the configuration, which is the default global installation directory of NPM. But if you use the NPM installation package multiple times, you will see two paths, cache and prefix, as shown below:

The first installation is as shown

Multiple installations as shown

3. Create two new folders in the file D:\nodejs (this is the path of the answerer's own, where you just installed the two folders where you just installed) file, named node_cache and node_global respectively. As shown below:Insert picture description here
4. Go back to the black window of "Command Prompt" and execute the following two commands:
npm  config set prefix "E:\node.js\node_global"
npm  config set cache "E:\node.js\node_cache"
The prefix and cache are followed by the path of your own folder. Do not reverse the order.
After the execution is successful, you can use the npm config ls command to view the configuration results.
5. Then enter the command npm install -g cnpm --registry=https://registry.npm.taobao.org in the "command prompt window".
This command code means to use Taobao NPM mirror
Then modify the npm Taobao data source
npm config set registry https://registry.npm.taobao.org
It is very slow to use the official image of npm directly in China. Taobao NPM image is recommended here.
Taobao NPM mirror is a complete npmjs.org mirror. You can use this instead of the official version (read-only). The synchronization frequency is currently every 10 minutes to ensure that it is synchronized with the official service as much as possible (here manually like Ali).

After installation, you can use the cnpm command to install the module:
For example:

$ cnpm install [name]

Three, configure environment variables

1. After verifying the configuration is successful, environment variables need to be configured. How to find environment variables? Hahaha, this is a sad (funny) story. The answer is that the Lord’s friend Tiga (you are right, it is the ancient giant Tiga Ultraman) did not find it.
2. The environment variables are in My Computer—>Properties—>Advanced System Settings—>Environment Variables—System Variables.
3. In the system variables, find the Path path, then click Edit, go in and click New, and then save the node.js path and node_global path. as the picture shows:

Insert picture description here

4. If it appears that'npm' is not an internal or external command, nor an executable program or batch file. This error, don’t panic, don’t be frightened, it’s just that the environment variables have not been configured successfully, just configure it again, if it doesn’t work, you can program for Baidu, or answer the main QQ, I can’t solve it, I’ll ask Daniel solve.
Seeing that this is done, it means you are great. If you have any questions, you can contact the answerer QQ2662395950. Although the answerer is also very good, the answerer is thick-skinned and will consult Daniel.

Guess you like

Origin blog.csdn.net/ni15534789894/article/details/111182962