DEV Community

Boris Shulyak
Boris Shulyak

Posted on

Manage project dependencies correctly

Choosing npm packages

Suppose you need to select a library, and you already know the requirements for which you are searching for this library. Here's what to consider when making the final decision:

  • Bundle size. - Compare the bundle size of each package using https://pkg-size.dev/.
  • Over engineering. - Evaluate how much unnecessary functionality this package offers. If it affects the bundle size, it's better to look for alternatives.
  • Popularity. - The number of GitHub stars and monthly downloads.
  • Activity. - How recently and how often the package has been updated? Activity in terms of issues and pull requests.
  • Code quality. - Read the source code of the package.

Updating npm package versions

  • Do not hurry to upgrade to major versions (especially in the context of big frameworks like Next.js), waite for at least 1-2 minor/patch versions afterward (unless it is needed and we embraced the risks).
  • When updating a version, carefully read the package's Changelog to avoid breaking changes.
  • Test all the functionality related to the updated package.

How to manage dependency versions

  • Strictly specify versions of all npm packages. - Do not use any symbols (^, ~, etc.) - this can lead to sudden bugs, as you might easily overlook that some packages have been updated, miss testing-related functionality, fail to inform QA about it, and as a result, deliver bugs to production.
  • Use dependabot.

Choosing a Dependency Manager

  • Use pnpm - This is just one recommendation, but it's too big of a topic to discuss here.

Read More

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay