According to the comment in node.js file src/node.js, line 55, and this discussion thread about the topic (Standalone? – nodejs):
// To allow people to extend Node in different ways, this hook allows
// one to drop a file lib/_third_party_main.js into the build
// directory which will be executed instead of Node's normal loading.
So I figured I could do something like this:
git clone https://github.com/joyent/node \
&& cd ./node \
&& echo 'console.log("Hello, World!");' > lib/_third_party_main.js \
&& ./configure
&& make -j4
But the resulting executable at “./node” just runs the normal REPL loop (or main module if an argument is given) as though the “third party main” module wasn’t detected. I was hoping the executable would instead print “Hello, World!” (per my custom main module) and exit so I could build a statically linked executable for simple distribution of a node-based application.
Any idea how to get this “standalone” build via “_third_party_main” working?
Didn’t automatically compile in for me either. It’s up to the build system to compile that JS file into the main executable, so it looks like it’s not doing that automatically.
It works if I add
'lib/_third_party_main.js'to the node.gyp file’s'library_files'key, so maybe just stick with that?