How to build node.js on linux into one stand-alone binary (including dependencies)?

For some reasons I would like to build Node.js into one linux binary which includes all dependencies, and, as a result, when run it does not “look” for other dynamically linked libs.

Is there a way how to statically link & bundle all necessary components so I would have one robust executable which I would call with “./node “? Note: I am not looking for wrapping JS sources with Node.js runtime to create one application.

I understand this may be demanding as for memory and resulting data overhead, but this is for some research so it won’t be production-used.

To have something to start from, I tried building Node.js from sources, and I would expect that with some build parameters/flags I could achieve bootstrapping all dependencies into statically linked binary, but I cannot find the way around. I checked the docs at github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms but it does not provide an answer.

Read more here: Source link