Make Sure You Can Switch

Nicholas C. Zakas on the idea that we have choice in server-side JavaScript runtimes now, and you should be careful.

… it makes sense to preserve the ability to switch runtimes easily. It doesn’t matter if you want to use Node.js or Deno or Bun in production right now. What you really want is the ability to change your mind later with as little pain as possible.

Here’s his advice (truncated for brevity):

  1. Don’t use Deno- or Bun-specific APIs. Stick with Node APIs that are already supported in Deno and Bun.
  2. Use the “node:” prefix for Node.js internal modules. Node works just fine when using the “node:” prefix, so you can ensure compatibility across all three runtimes.
  3. Use npm and JSR packages, not HTTP module specifiers. Deno is still the only runtime to support URL modules, so it’s best to stick with npm and JSR packages, which can be used across all three.
  4. Use package.json for dependencies. Don’t use the proprietary file formats which have no advantages.
  5. Always run CI with Node, too. Even if you’re deploying to Deno or Bun, run CI in Node.

Wanna learn Node.js deeply?

Leave a Reply

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

Did you know?

Frontend Masters Donates to open source projects. $363,806 contributed to date.