2

Forgive me, for I am still pretty new to NodeJs.

So I have a NodeJs program with a "node_modules" folder that contains about 70 modules which I do not remember adding most of them. I am trying to figure out how to easily know which ones I can safely delete. Is there a way to figure this out? I thought I could just look at the imports at the top of the code, but there are some that are used internally that are implicitly imported.

DChalo123
  • 165
  • 3
  • 11

1 Answers1

2

Those are modules that makes your app run. Don't delete them. Some are important for security, some are needed for parsing etc. If you have not installed a certain module, then that means node needs it to run on your machine or server. If you have installed it yourself and forgot the module and want it gone, then the one place your can find your installed modules is in the package.json. All the things you have imported should be inside "dependencies". If you are not using them, that means, you have it in there for nothing. Now make sure not only to delete the folder from "node_modules" but also delete the name from "package.json" and "package.lock.json"

eyoeldefare
  • 2,136
  • 1
  • 15
  • 25