S
S
Stasinskii Fil2016-03-19 22:27:04
Node.js
Stasinskii Fil, 2016-03-19 22:27:04

Why do NPM packages take a long time to install, if not at all?

The essence of the problem is that npm packages are not installed for a long time or even at all, and the node_modules folder does not appear. I tried reinitialization and updated the json file, and just separately tried to install some module, the problem is the same on both Windows and Linux. Node v5.8.0 npm v3.7.3
Who can tell what it is and how to solve this problem, thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gennadich, 2021-03-30
@Psychosynthesis

This problem occurs in many versions of npm and NodeJS, and, as far as I understand, in some cases it may still be relevant, so I decided to answer the question now.
As far as I understood from googling, if we exclude the most obvious problem (“you have problems with the Internet”), then there can be many reasons for this behavior. I will tell you how I ended up in a similar situation and what I did to solve the problem, maybe it will be useful to someone.
In my case, an annoying bug with Babel aliases once appeared, which eventually required updating it, and after updating Babel, the project simply stopped building. I had to update Node, then npm, etc. As a result, the project was still assembled, but there was a problem voiced in the question - npm ci (this is almost the same asnpm install , only installs strictly those versions that are specified in package-lock) began to work very slowly, hanging for a long time on various random packages.
I assumed that there could be two reasons for this situation in the end:

  1. Node and/or npm cache got clogged - I tried npm cache clean --force and deleted all the folders created during the build, as well as all the cache folders I found, it did not help. In the end, I didn't think of anything better than to completely remove Node and npm from the system, which is not so easy to do on Linux.
    To remove the node, this package https://github.com/brock/node-reinstall helped me a lot (although I also had to search and delete folders with the names node and npm with my hands) ... For a fresh installation of the node on the network, it is advised to use NVM, however, in my personal opinionNVM is a crappy, confusing and crooked shit with clumsy documentation and constantly changing command syntax, so I don’t advise doing this (yes, I tried it, it works, but there are always some problems with it, so without having to have two different it is better not to install nodes on one machine).
    It is better to install the required version of the node according to the instructions from the off site for your system using the standard package manager. At least in the case of Ubuntu 20.04 it worked perfectly. Instructions for Ubuntu and Debian-based distributions are here: https://github.com/nodesource/distributions/blob/m...
    In general, there are many options at the link, but here is an example for installing the 14th version in the easiest way:
    # Using Ubuntu
      curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
      sudo apt-get install -y nodejs
    
      # Using Debian, as root
      curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
      apt-get install -y nodejs

  2. The second possible option - the problem is that for new versions of npm, the servers of remote repositories of some old packages have somehow changed, due to their obsolescence (I noticed that when trying to install packages, most often "freezes" happened precisely on old packages, such as the third version of TypeScript).
    I, unfortunately, do not know the nuances of the npm repository system, so this is just a guess. In this case, there is only one recommendation - try to update the packages to the latest versions, and, if possible, get rid of the depricated packages.

I don’t pretend to be true, maybe this is just a bug in one of the npm versions or even a specific NodeJS + npm bundle. However, perhaps someone will come in handy proposed by me the solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question