How to solve the network error problem when npm install axios or npm install axios -g

❓ Problem Description

When the npm install axios -g is installed globally, the progress bar is stuck and the following screen appears:

It seems like you’re having network connectivity problems executing the command npm install axios -g. There may be a problem with your network settings or you are using a proxy server..

⁉️ Solution:

1.Switch to the Taobao image source and re-execute the installation command:

npm config set registry https://registry.npm.taobao.org

2.Use another installation command to resolve:

npm install axios --save --legacy-peer-deps

3.If image is still stuck: Switch to official

npm config set registry https://registry.npmjs.org/ 

This sets the npm image source as the official source (https://registry.npmjs.org/).

After you execute this command, npm uses the official source to download and install the package. You can verify that the changes take effect by running the following command:

npm config get registry 

If the output is https://registry.npmjs.org/, the official source has been successfully switched back.

4.Rerun the installation command:

npm install axios --save --legacy-peer-deps

If you see the following interface, the installation is successful (you may be prompted with a vulnerability):

Four medium severity vulnerabilities are mentioned in the output. To resolve these vulnerabilities, you can run the following command to perform an npm audit and fix the issue:

npm audit fix

This document is transferred from https://blog.csdn.net/weixin_69005296/article/details/136079138,If there is any infringement,Please contact to delete。.