Avoid NPM Headaches With Good Practices

Ahmed Sakr
The Startup
Published in
4 min readAug 5, 2020

--

You might have faced issues with npm install automatically picking up a new version of a dependency that broke your build. And you might have also heard of the incident where a programmer deleted several npm packages that millions of people depended on. Fortunately, there are some good practices we can adopt to minimize our exposure to external factors.

npm versioning standard

npm packages follow the major.minor.patch versioning format (e.g., 7.3.4). While the numbers themselves are arbitrary, how they change is not:

  • MAJOR versions are upgraded when a major overhaul of existing interfaces is committed. This often entails backwards incompatibility. If you depend on a dependency that you’re upgrading major versions, you might have to modify your code.
  • MINOR versions are upgraded when new features or APIs have been added the product. Since existing interfaces are not modified in a backwards-incompatible manner, you may safely upgrade to a minor version without modifying your code.
  • PATCH versions are upgraded when a hotfix or implementation changes are made that are inconsequential to the users. You can almost always upgrade patch versions without worry.

If you would like to learn more about this versioning protocol, you can read more…

--

--