1

As per title, I have been developing my react app in a very bad manner.

Since I worked in an offline environment, whenever I needed to install a new package top be used in my application, I would manually copy it into my node_modules folder. The problem is that I normally do not update my package.json file with the newly installed dependency.

Because of this, after a long time, my node_modules folder grew quite large (300 ish).

When I send the application to my colleauge to develop and he ran npm install "some package", npm deletes more than half of my manually installed packages (ouch). (Also this explains npm's behavior on this https://github.com/npm/npm/issues/17929#issuecomment-322881421 )

Is there a way for me to update my package.json file with all of my dependencies manually installed in my node_modules folder? Besides having to manually type all 300 plus modules (+ modules that are downloaded as it is a dependancy of another node_module)?

Im pretty desperate so any advice will really be appreciated.

1 Answers1

0

You could try deleting your package-lock.json, run npm shrinkwrap, and then paste the dependencies in the generated npm-shrinkwrap.json into your package.json. This will be way more verbose than your package.json would normally be, because I think it will explicitly list the dependencies of all your dependencies (like package-lock.json), but it should give you a file that your application can be installed from by a colleague.

elethan
  • 16,408
  • 8
  • 64
  • 87
  • How does npm-shrinkwrap record the dependency usage from node_modules? Doesn't it just create a shrinkwrap file with locked depdencies? – PrivateOmega Apr 09 '19 at 02:58
  • @KiranMathewMohan I am not sure exactly how it works, but I know that it can work without a package-lock.json, or a package.json. My understanding is that it can figure out the dependency tree from node_modules alone if necessary, which sounds like what OP is looking for. I could be wrong though; I have not used shrinkwrap extensively. – elethan Apr 09 '19 at 12:51
  • It is exactly what OP wants to do. Maybe I will try it out also and see if I can figure it out – PrivateOmega Apr 09 '19 at 12:58
  • Ill try this out and see how it goes aite! – INeedInsecticideToKillBugs Apr 11 '19 at 04:25