Disable REPL in node
binary
#5079
-
Hi! Is there some configure options to disable REPL? I need |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
By default, Node.js has no built-in option to disable the REPL interactive shell entirely at the binary level. Running node with no arguments launches the REPL, but there is no official CLI flag to disable it globally and i believe there is no any built-in method that does this job globally. I have this solution for now - Custom wrapper script: Create a small wrapper that checks if a filename is passed. If not, exit or show an error; otherwise, exec Node with the supplied file. Set this script as the intended entry point instead of the raw node binary. (Very advanced even i cannot do it precisely but there is chances) - You could patch the source code so that the binary exits with an error if no script is given. This requires compiling your own version of Node.js (source code). Also , please mention your working environment to figure out more precisely.(like docker, production etc.) |
Beta Was this translation helpful? Give feedback.
By default, Node.js has no built-in option to disable the REPL interactive shell entirely at the binary level. Running node with no arguments launches the REPL, but there is no official CLI flag to disable it globally and i believe there is no any built-in method that does this job globally.
I have this solution for now -
Custom wrapper script: Create a small wrapper that checks if a filename is passed. If not, exit or show an error; otherwise, exec Node with the supplied file. Set this script as the intended entry point instead of the raw node binary.
(Very advanced even i cannot do it precisely but there is chances) - You could patch the source code so that the binary exits with an erro…