Join my Alpine.js course on Udemy for free 👀

Removing unused node modules with yarn

March 11, 2021  ‐ 1 min read

Every now and then I install a node module to test something out. Or haven't decided which package to use for a certain use-case and install multiple packages that do the same thing.

You can remove those packages from the dependencies section in your package.json, but that doesn't remove the package from the node_modules folder. Yarn has an autoclean command that removes unnecessary dependencies.

$ yarn autoclean

What about npm?

npm offers a similar command to remove unnecessary dependencies; prune.

$ npm prune