Node.js — Show Your NODE_MODULE_VERSION

Switching to a new Node.js major version requires you to freshly install dependencies. You may receive the following error when forgetting to re-install dependencies:

Error: The module '/home/futurestudio/projects/futurestud.io/node_modules/bcrypt/lib/binding/bcrypt_lib.node'  
was compiled against a different Node.js version using  
NODE_MODULE_VERSION 64. This version of Node.js requires  
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing  
the module (for instance, using `npm rebuild` or `npm install`).  

The error message tells to you run the npm rebuild or npm install commands. These commands are your first step. If that doesn’t help, you may need to check your Node.js version compatibility with the related dependency.

When running into this error, we can’t translate the NODE_MODULE_VERSION to the actual Node.js version. That’s the reason to write this tutorial. We’re showing you how to find the node module version of your installed Node.js version. Also, you’ll find a list of Node.js versions mapped to their node module versions.

Node.js Series Overview

  1. String Replace All Appearances
  2. Remove All Whitespace From a String in JavaScript
  3. Generate a Random ID or String in Node.js or JavaScript
  4. Remove Extra Spaces From a String in JavaScript or Node.js
  5. Remove Numbers From a String in JavaScript or Node.js
  6. Get the Part Before a Character in a String in JavaScript or Node.js
  7. Get the Part After a Character in a String in JavaScript or Node.js
  8. How to Check if a Value is a String in JavaScript or Node.js
  9. Check If a String Includes All Strings in JavaScript/Node.js/TypeScript
  10. Check if a Value is a String in JavaScript and Node.js
  11. Limit and Truncate a String to a Given Length in JavaScript and Node.js
  12. Split a String into a List of Characters in JavaScript and Node.js
  13. How to Generage a UUID in Node.js
  14. Reverse a String in JavaScript or Node.js
  15. Split a String into a List of Lines in JavaScript or Node.js
  16. Split a String into a List of Words in JavaScript or Node.js
  17. Detect if a String is in camelCase Format in Javascript or Node.js
  18. Check If a String Is in Lowercase in JavaScript or Node.js
  19. Check If a String is in Uppercase in JavaScript or Node.js
  20. Get the Part After First Occurrence in a String in JavaScript or Node.js
  21. Get the Part Before First Occurrence in a String in JavaScript or Node.js
  22. Get the Part Before Last Occurrence in a String in JavaScript or Node.js
  23. Get the Part After Last Occurrence in a String in JavaScript or Node.js
  24. How to Count Words in a File
  25. How to Shuffle the Characters of a String in JavaScript or Node.js
  26. Append Characters or Words to a String in JavaScript or Node.js
  27. Check if a String is Empty in JavaScript or Node.js
  28. Ensure a String Ends with a Given Character in JavaScript or Node.js
  29. Left-Trim Characters Off a String in JavaScript or Node.js
  30. Right-Trim Characters Off a String in JavaScript or Node.js
  31. Lowercase the First Character of a String in JavaScript or Node.js
  32. Uppercase the First Character of a String in JavaScript or Node.js
  33. Prepend Characters or Words to a String in JavaScript or Node.js
  34. Check if a String is a Number
  35. Convert a String to Buffer
  36. Prevent Line Breaks in String Template Literals
  37. How to Implement a Custom `toString` Method (Coming soon)
  38. What Is `Symbol.toStringTag` and How to Use It (Coming soon)

Retrieve Your NODE_MODULE_VERSION in Node.js

You can retrieve your current NODE_MODULE_VERSION using Node.js’ command line tool. Run node in your terminal to enter the Node.js REPL.

Within the Node.js REPL run process.versions to retrieve the object of library versions bundled with your Node.js installation. Look for the process.versions.modules key to find your current NODE_MODULE_VERSION:

$ node

> process.versions
{
  node: '20.9.0',
  acorn: '8.10.0',
  ada: '2.6.0',
  ares: '1.19.1',
  base64: '0.5.0',
  brotli: '1.0.9',
  cjs_module_lexer: '1.2.2',
  cldr: '43.1',
  icu: '73.2',
  llhttp: '8.1.1',
  modules: '115',        # 👈 this is the line you’re looking for
  napi: '9',
  nghttp2: '1.57.0',
  nghttp3: '0.7.0',
  ngtcp2: '0.8.1',
  openssl: '3.0.10+quic',
  simdutf: '3.2.17',
  tz: '2023c',
  undici: '5.26.3',
  unicode: '15.0',
  uv: '1.46.0',
  uvwasi: '0.0.18',
  v8: '11.3.244.8-node.16',
  zlib: '1.2.13.1-motley'
}

You may also directly access the node modules version via process.versions.modules within the Node.js REPL:

$ node

> process.versions.modules
'115'  

You can also see the Node.js version number of your installation within the process.versions.node property. In this example, we’re running Node.js version 20.9.0.

Node.js NODE_MODULE_VERSION by Version

Here’s a list of node module versions by Node.js version. We’re only listing the stable releases, including those already end-of-life:

  • Node.js 6.x has node module version 48
  • Node.js 8.x: has node module version 57
  • Node.js 10.x has node module version 64
  • Node.js 12.x has node module version 72
  • Node.js 14.x has node module version 83
  • Node.js 16.x has node module version 93
  • Node.js 18.x has node module version 108
  • Node.js 20.x has node module version 115
  • Node.js 22.x has node module version 127

We skipped listing the “current” releases because you should avoid using them in production. If you’re missing a node module version in the list, it’s probably one in between two stable releases.

Enjoy!

Explore the Library

Find interesting tutorials and solutions for your problems.