#1143·nexe

nexe with NodeJS 24 fails to bundle third-party libraries

Author: sjlonglandCreated Mar 19, 2026Updated Sep 5, 2026
Labelsbug

What happened:

We've got an existing build system that uses nexe inside the official ALpineLinux-based NodeJS Docker container that compiles an application to a native binary (mostly to hide the source code from people ignorant of the strings command in Unix). This has worked in a number of NodeJS releases up to and including NodeJS 20, but in 24, the application fails to find libraries that were installed into node_modules.

For the purpose of this bug, I've re-created the issue with a far simpler project to demonstrate the issue:

https://bitbucket.org/sjlongland/nexe-node24-poc/src/master/

  • The application simply uses the bunyan logger to emit a "Hello world" (bunyan is where we're seeing the issue at the moment, but other modules could be affected too.)
  • The Dockerfile installs dependencies needed to build NodeJS, installs nexe globally, then instructs nexe to build the project (--resource is given to bundle libraries), then the build environment is cleaned up and the resulting binary run.

In NodeJS v24, we see output like the following:

bash
rm c7e2a72525f46135ca7c4eb11f8193b3d83f32f1009816b1b13e406ed0d873eb.intermediate 6169c4abf0c93be096dd092d1dba1fd12f81e1a01d8b5bc8be809c4cdfa04a77.intermediate e36ff7e8f40280f91a81efd777c8dd2a71f4c493c5e71f8a1b7a99c4258e862d.intermediate 3c26225b195ad685fb403935f6b0da008665c66794ee6f5384ea9c9b4e24bd9a.intermediate
if [ ! -r node ] || [ ! -L node ]; then \
  ln -fs out/Release/node node; fi
- Compiling Node...
✔ Compiling Node...
- Node binary compiled
- Node binary compiled
✔ Writing result to file
- Entry: 'index.js' written to: ../../usr/local/bin/nexe-node24-poc
✔ Entry: 'index.js' written to: ../../usr/local/bin/nexe-node24-poc
- Finished in 21987.46s
✔ Finished in 21987.46s
node:internal/modules/cjs/loader:1481
  throw err;
  ^

Error: Cannot find module 'bunyan'
Require stack:
- /usr/local/bin/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1478:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1088:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1093:22)
    at Module._load (node:internal/modules/cjs/loader:1264:25)
    at wrapModuleLoad (node:internal/modules/cjs/loader:277:19)
    at Module.require (node:internal/modules/cjs/loader:1578:12)
    at require (node:internal/modules/helpers:152:16)
    at Object.<anonymous> (/usr/local/bin/index.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1834:14)
    at Object..js (node:internal/modules/cjs/loader:1965:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/bin/index.js' ]
}

Node.js v24.14.0
The command …snip for brevity… returned a non-zero code: 1

What you expected to happen:

Something similar to what it does on NodeJS 20:

bash
rm d95bab3b5ef5844b3a45464d8fbc0dcbcebcf2ac.intermediate 295043a7354bd9de15db47b719d89d079b40c354.intermediate 08751576e12f755f9d7e47162bed8a4c68121052.intermediate 52bdbde6c15d190f991708a45e8c722ede5ac26e.intermediate
if [ ! -r node ] || [ ! -L node ]; then \
  ln -fs out/Release/node node; fi
- Compiling Node...
✔ Compiling Node...
- Node binary compiled
- Node binary compiled
✔ Writing result to file
- Entry: 'index.js' written to: ../../usr/local/bin/nexe-node24-poc
✔ Entry: 'index.js' written to: ../../usr/local/bin/nexe-node24-poc
- Finished in 12136.867s
✔ Finished in 12136.867s
{"name":"nexe-node24-poc","hostname":"f6aa71b972bc","pid":1,"level":30,"msg":"Hello World","time":"2026-03-18T03:24:12.329Z","v":0}
 ---> Removed intermediate container f6aa71b972bc
 ---> 5bb3c5b932cd
Successfully built 5bb3c5b932cd
Successfully tagged nexe-node24-poc:node20

How to reproduce it (as minimally and precisely as possible):

bash
git clone --depth=1 https://bitbucket.org/sjlongland/nexe-node24-poc.git
cd nexe-node24-poc
docker build -t nexe-node24-poc .

Anything else we need to know?:

Environment:

  • Platform(OS/Version): AlpineLinux 3.23
  • Host Node Version: NodeJS 24.14.0
  • Target Node Version: NodeJS 24.14.0
  • Nexe version: 5.0.0-beta.4
  • Python Version: 3.12.12