# RequireError: unable to load module

**URL:** <https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242>\
**Category:** Help\
**Created:** [September 5, 2023, 2:17pm UTC](https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242 "2023-09-05T14:17:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martien](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/martien/32/470_2.png) [@Martien](https://talk.observablehq.com/u/Martien)\
**Post date:** [September 5, 2023, 2:17pm UTC](https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242/1 "2023-09-05T14:17:59Z")

</div>

This worked fine until now:

> `F = require("fraction.js")`

However, I now have to use:

> `F = require('fraction.js@4.0')`

Is adding the version number mandatory? I’d like to always get the latest version, therefore not specifying the version number (assuming newer versions are always upwards compatible). Or is that considered unwise and bad practice?

So, my guess is that something is missing somewhere to make just `"fraction.js"` refer to the most recent revision?!

Is that something Fraction.js can/should fix on the JS module side? (I’m a lay person in that area).

Some more confusion: on [https://semver.npmjs.com](https://semver.npmjs.com) I see that current revision is 4.3.6?! But when I `require('fraction.js@4.3.6')`, I get a load error.

I assume it is related to [Fraction.js » Native ES module support](https://github.com/rawify/Fraction.js/commit/47102bdde4d8bf8f6d0d24b8aef3b50b41ed9949).

Wonder if this is an Observable or Fraction.js issue.

Also see [Fraction.js » Issue 70](https://github.com/rawify/Fraction.js/issues/70).

---

<div class="post-metadata">

**Author:** ![mythmon](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mythmon/32/8504_2.png) [@mythmon](https://talk.observablehq.com/u/mythmon)\
**Post date:** [September 5, 2023, 3:52pm UTC](https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242/2 "2023-09-05T15:52:58Z")

</div>

Without commenting on the rest of your post, and I haven’t looked at this library in particular, I’ll comment on this part in particular:

> [@Martien](#):
>
> I’d like to always get the latest version, therefore not specifying the version number (assuming newer versions are always upwards compatible). Or is that considered unwise and bad practice?

I think this is bad practice. Many libraries break compatibility with upgrades, even between major versions. If you want any software you write (including Observable notebooks) to work going forward, it is worth while to pick specific versions of your dependencies and stick with them. Otherwise you’ll constantly be chasing compatibility issues like this.

---

<div class="post-metadata">

**Author:** ![Martien](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/martien/32/470_2.png) [@Martien](https://talk.observablehq.com/u/Martien)\
**Post date:** [September 5, 2023, 3:59pm UTC](https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242/3 "2023-09-05T15:59:42Z")

</div>

I agree.

Do you know if there are conventions about major and minor and subminor versions? For example, when a major revision number changes, it may imply incompatible changes (e.g. API, behaviour, side-effects). And when subminor versions change, it always is compatible change?

---

<div class="post-metadata">

**Author:** ![mythmon](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mythmon/32/8504_2.png) [@mythmon](https://talk.observablehq.com/u/mythmon)\
**Post date:** [September 5, 2023, 4:22pm UTC](https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242/4 "2023-09-05T16:22:27Z")

</div>

There is a commonly cited convention called Semver (which you seem to be at least partially aware of). Semver has a lot of details, but the basics boil down to this: If you have a version number like `X.Y.Z`, then `X` is called the _major version number_, `Y` is called the _minor version number_, and `Z` is called the _patch version number_.

If a change to the software is both backwards and forwards compatible, then a new version that includes that change must increment the patch number. This is often bug fixes or documentation changes.

If a change to the software introduces changes that are backwards compatible, but not forward compatible, then the minor patch number must be incremented. That means that software written for 2.5.1 would be expected to work in 2.6.0, but that software written for 2.6.0 can’t be guaranteed to work with 2.5.1. These kind of changes are usually new features.

Finally, if a change introduces a change that is not backwards compatible, it must increment the major number. Software written for 2.5.1 can not be guaranteed to work with 3.0.0. This is often major new features, or changes in the support of underlying languages (like dropping support for old versions of Node, for example).

(There is more to Semver than that. If you want to know more you can read about it here: [https://semver.org/](https://semver.org/))

So, with all that in mind **in theory** an upgrade from 4.0 to 4.3.6 **should** not break compatibility. However, as you’ve seen first hand this is not always true. What one person considers a breaking change another person might see as fixing a bug. And some projects use Semver-like versions without actually conforming to Semver.

---

<div class="post-metadata">

**Author:** ![Martien](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/martien/32/470_2.png) [@Martien](https://talk.observablehq.com/u/Martien)\
**Post date:** [September 5, 2023, 8:50pm UTC](https://talk.observablehq.com/t/requireerror-unable-to-load-module/8242/5 "2023-09-05T20:50:35Z")

</div>

Thanks for your clear and elaborate reply and reference to [server.org](http://server.org). Very helpful and insightful.
