9

Today i decided to start react native cli project. Everything works great since i want to add new lib of course using npm . So i ran npm install ... . And this command always stuck on Image

idealTree: timing idealTree Completed in 3440ms

And nothing happened. So i tried to ran

npm install --verbose

And again stuck on the same place. Also clear cache npm cache clear --force and nothing happened again. I don'n know how to fix this

Hristo Ivanov
  • 145
  • 1
  • 5

5 Answers5

11

I have had npm install freeze on me numerous times, lately. I'm not sure of the cause. When that happens I follow these steps:

  1. Kill the npm install process with ctrl+c.
  2. Delete node_modules. If there are files that you cannot delete because they are currently in use, that may mean that the npm install process was not successfully stopped. Try opening Task Manager and ending all nodejs and terminal processes. If this fails, restart your pc and then delete node_modules
  3. Clean cache and reinstall node_modules with npm cache clean --force && npm i
PhantomSpooks
  • 772
  • 5
  • 9
  • 1
    Probably this is overkill, npm cache virtually never needs cleaning. An answer below mentions `stopping the dev server` (that is probably locking some node_modules folder), should work just fine. In this answer's second step OP does the same by `killing nodejs processes`. – Preda7or Apr 19 '22 at 12:56
7

This has happened to me a few times before and all I had to do was kill my dev server before running npm install.

Hope that helps as well!

soygreg
  • 81
  • 1
  • 2
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31470069) – Barry Michael Doyle Apr 11 '22 at 08:58
  • 1
    Perhaps "stop the server before attempting to run `npm install`" would fit the format? This solution worked for me without removing `node_modules`, possibly because it still involved "ending all nodejs and terminal processes" from the accepted answer. – dcwaters Apr 12 '22 at 14:49
0

I also faced this problem and the solution was simple by stopping all the "nodejs terminals" that are working outside. When you stop nodeJS Terminals running in the background, it will complete the current installation process. enter image description here

  • The screenshot doesn't seem to add value here. Additionally, this seems to be the same as other answers - consider adding more detail to yours too distinguish it as unique, if possible. – ryanwebjackson May 13 '22 at 13:05
0

When you want to add package on your project it is better to stop server before adding new package. I had same problem but after doing this it is solved.

0

When i opened my package.json i saw '~2.2.1' in front of react-native-gesture-handler which probably means that it was notinstalled properly Just close all terminals and then open task manager and kill all the processes corresponding to NodeJS. Then install it again. Hopefully it will resolve.

royam
  • 1