In front-end development, we often encounter running npm install to install the tool package and it always gets stuck. For this reason, we provide several solutions for your reference and learning. Please correct me for any shortcomings.
The first option is to check firstnpm agent to see if domestic mirroring has been used
//
Execute the following command to check whether it is a domestic mirror
npm config get registry
The following appears, indicating that it is a domestic image and does not need to be modified.
If not, change to domestic image and execute the following command
npm config set registry=https://registry.npmmirror.com
//执行以下命令查看是否配置成功
npm config get registry
Second option,Delete node_modules and re-npm install
The third option,Use yarn to install
// 全局安装yarn (mac需要加上sudo)
npm install -g yarn
// 成功后使用yarn install安装
yarn install
The fourth option,Use cnpm to install
// 全局安装cnpm (mac需要加上sudo)
npm install cnpm -g --registry=https://registry.npmmirror.com
// 成功后使用cnpm install安装
cnpm install