DEV Community

Discussion on: How to keep a healthy package.json

Collapse
 
leober_ramos33 profile image
Leober Ramos

Another thing I do is delete the package-lock.json file and create it again.

Why? Sometimes when I uninstall a dependency it is removed from the package.json and from the package-lock.json but its sub-dependencies are not, so at the end in the "node_modules" folder reside these dependencies that I am no longer using.

And deleting the file and creating it again with "npm install" lightens up the "node_modules" folder for me.

In addition, another tip would also be to install only the dependencies that are going to be used.

Collapse
 
meyruiz profile image
May

Hi Leober! I also delete the package-lock.json because of the same reasons you mentioned, though I'm not 100% sure if this is the best way to remove the sub-dependencies or if it is a good practice.

I totally agree on adding only the dependencies that are going to be used! Thanks for your input :)