Why you should version your Node dependencies using tilde

I’m going to assume you’re already familiar with SemVer and the NPM tilde extension. If not, get your eye holes around those links, particularly the second one.

Ever since I’ve been working on David I’ve seen a lot of version numbers for node projects. I’ve also authored a few npm packages and node projects myself. I find it hard understand why you wouldn’t use tilde to specify the versions of your dependencies. For example:

~1.0.2

This is shorthand for >= 1.0.2 < 1.1.0. It is saying: If the major or minor version increases then I need to retest my code to check it works on the new version, so don’t depend on that. Although, if there are bug fixes, I want them, and whilst I understand that a bugfix release could break my software, it isn’t meant to, so I’m willing to take the gamble.

The idea is that you’re allowing your dependencies to “self update” within a range that is safe to do so. This is really powerful and you should be using it.

I’ve seen a lot of absolute versions for dependencies, which is fine (you know who you are, you have your reasons), but I also see a lot of reckless version ranges: “>= 0.3.14″, “*”, “latest” which are just mad. How can you possibly know your code will still work as your dependencies transition between major and minor version numbers?

115 thoughts on “Why you should version your Node dependencies using tilde

  1. I visit day-to-day a few blogs and websites to read articles
    or reviews, except this weblog gives quality based
    writing.

  2. Hey I know this is off topic but I was wondering if you knew of any
    widgets I could add to my blog that automatically tweet my newest
    twitter updates. I’ve been looking for a plug-in like this for quite some
    time and was hoping maybe you would have some experience with
    something like this. Please let me know if you run into
    anything. I truly enjoy reading your blog and I look forward to your new
    updates.

  3. May I just say what a relief to uncover someone that truly
    knows what they’re talking about on the web. You certainly know how to bring
    an issue to light and make it important. More and more people ought to
    look at this and understand this side of your story.

    It’s surprising you are not more popular given that you surely possess the
    gift.

  4. Wow, superb blog layout! How long have you
    been blogging for? you make blogging look easy. The overall look of your website
    is excellent, as well as the content!

  5. Do you mind if I quote a couple of your posts as long as I
    provide credit and sources back to your blog?
    My website is in the very same niche as yours and my users would definitely benefit from a lot of the information you provide here.
    Please let me know if this alright with you. Appreciate it!

  6. I was recommended this web site by my cousin. I am not sure whether this
    post is written by him as no one else know such detailed about my trouble.
    You are incredible! Thanks!

  7. Pretty great post. I simply stumbled upon your blog and wanted to mention that I’ve truly loved
    surfing around your weblog posts. After all I will be subscribing in your rss feed and I am hoping you write once more soon!

    Here is my web-site … online casino usa

  8. With havin so much content do you ever run into any
    problems of plagorism or copyright infringement? My website has a
    lot of exclusive content I’ve either written myself or
    outsourced but it appears a lot of it is popping it up all over the web without my permission. Do
    you know any methods to help protect against content from being stolen? I’d really appreciate
    it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>