I am building a CLI tool with node, and want to use the fs.promise
API. However, when the app is launched, there's always an ExperimentalWarning
, which is super annoying and messes up with the interaction prompts. How can I disable this warning/all warnings?
I'm testing this with the latest node v10 lts release on Windows 10.
To use the CLI tool globally, I have added this to my package.json
file:
{
//...
"preferGlobal": true,
"bin": { "myapp" : "./index.js" }
//...
}
And have run npm link
to link the ./index.js
script. Then I am able to run the app globally simply with myapp
.
After some research I noticed that there are generally 2 ways to disable the warnings:
- set environmental variable
NODE_NO_WARNINGS=1
- call the script with
node --no-warnings ./index.js
Although I was able to disable the warnings with the 2 methods above, there seems to be no way to do that while directly running myapp
command.
The shebang I placed in the entrance script ./index.js
is:
#!/usr/bin/env node
// my code...
I have also read other discussions on modifying the shebang, but haven't found a universal/cross-platform way to do this - to either pass argument to node itself, or set the env variable.
If I publish this npm package, it would be great if there's a way to make sure the warnings of this single package are disabled in advance, instead of having each individual user tweak their environment themselves. Is there any hidden npm package.json
configs that allow this?
Any help would be greatly appreciated!