• notice
  • Congratulations on the launch of the Sought Tech site

The solution to the problem that npm install always gets stuck

problems encountered

npm install -g commitizen

When installing the commitizen tool, I found that the progress bar has been stuck, and I believe many friends have encountered it. The reason should be that the domestic network connection npm speed is slow, and even many things cannot be downloaded and installed. So how to solve this problem?


Method 1: Install the cnpm image

This is a more common method, and I used this method first.

For the installation method of cnpm, refer to http://npm.taobao.org/

npm install -g cnpm --registry=https://registry.npm.taobao.org

Just enter the above command in cmd, and then use cnpm to install

cnpm install -g nodemon

The following operations are similar to those without mirroring.


Method 2: Use a proxy registry

After checking some information on the Internet, I decided to use the proxy method. The method is also very simple, that is,

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

Then the subsequent install and other commands still operate through npm, not cnpm.


Postscript added:

There are bugs in npm install, you can install yarn instead.

step:

Yarn, the command line tool for React Native (react-native-cli)

Yarn is an alternative to npm provided by Facebook to speed up the download of node modules. React Native's command-line tools are used to perform tasks such as creating, initializing, updating projects, running packagers, and more.

npm install -g yarn react-native-cli

After installing yarn, set the mirror source in the same way:

yarn config set registry https://registry.npm.taobao.org --globalyarn config set disturl https://npm.taobao.org/dist --global

If you encounter EACCES: permission denied permission error, you can try to run the following command (Linux only): sudo npm install -g yarn react-native-cli.

After installing yarn, you can use yarn instead of npm, for example, use yarn instead of npm install command, and use yarn add to replace the name of a third-party library with npm install --save.

Note: At present, npm5 (the latest version is 5.0.4 at the time of posting) has a problem that other libraries will be deleted when installing new libraries, resulting in the project not running normally. Please try to use yarn instead of npm operations.


Reprint and Reference

https://blog.csdn.net/WXF_Sir/article/details/112944559

Solve the problem that npm install is always stuck

https://www.cnblogs.com/pijunqi/p/14362901.html

Solve the small embarrassment that npm install is stuck
https://www.cnblogs.com/wenbinjiang/p/11062959.html


Summarize

So far, this article about the problem of npm install always getting stuck is introduced here. For more related npm install stuck, please search the previous articles of Yunhaitian Tutorial or continue to browse the related articles below. A lot of support for Yunhaitian tutorial!

Original address: https://blog.csdn.net/qq_39595769/article/details/123055196


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+