So, node options is also very useful when you are running another application, but you don't have control over the node command. For example, when you are running something with NPX. A use case I find very useful is to pass node option –abort on uncaught exception with NPX. So, in this way, if there is a bug, I can see it without being swallowed by NPX. So, what do we do now? We create this environment variable called node options, and we pass some of the flags that are allowed inside the node options. And so, we can remove all the flags after the node command, and we can see we are just running three flags and it works in the same way.
So, we can also use –mfile to set the node options from a file. So, we create a .mfile, we put inside this file the node options, and then we pass it. So, if in the past you were using .env, now you don't need to install it anymore because it's built in the Node.js application. So, we create a file, we put the node options inside, and then we run node –mfile and the same flags as before. Watch, experimental, test, coverage, and test. We cannot put those flags inside the node options because those are not allowed. All right.
So, this is an improvement, but it's still not great. I think we can do much, much better than this. Like, still you have .mfile without autocompletion for IDE. You have to know which flags are allowed, which are not allowed. It's suboptimal developer experience. We can do better. So, what Node.js is missing is actually a file-based initialization configuration. So, the name sounds scary, but if you are used to other languages, PHP has one, Java has one, .NET has one, Ruby has one. All major programming languages' runtimes have one. And also, other JavaScript runtimes have one. There is the dna.json and the banfig.toml. So, Node.js needs something similar to this to configure the application with just a file. All right. So, this has been discussed for years. This discussion is from July 2024. And there was a lot of back and forth with the Node.js maintainers to, like, how do we do this and what is the best way we can do this? A lot of back and forth. And this was February 2025.
Comments