-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
Cannot disable warnings when node is launched via a shell script. #10802
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: nodejs#10802 PR-URL: nodejs#10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: nodejs#10802 PR-URL: nodejs#10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: nodejs#10802 PR-URL: nodejs#10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: #10802 PR-URL: #10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: #10802 PR-URL: #10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: nodejs/node#10802 PR-URL: nodejs/node#10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
What's the solution? When I try putting this at the top of my file:
I just get:
|
@mnpenner
it works. :) |
@Doragd Huh? How would that work... the file contains JavaScript, it'll syntax error on |
@mnpenner According to the link from @bnoordhuis, looks like it depends on the OS. Does anyone have a cross-platform way to set the environment variable? Still haven't found any after researching and experimenting for a while. :( |
@hexrcs |
@mnpenner |
@Doragd We're talking about an executable .js file, not a .sh file which subsequently runs node. |
I am now using a launcher script to spawn a #!/usr/bin/env node
const { spawnSync } = require("child_process");
const { resolve } = require("path");
// Say our original entrance script is `app.js`
const cmd = "node --no-warnings " + resolve(__dirname, "app.js");
spawnSync(cmd, { stdio: "inherit", shell: true }); If you only wanted to disable the warnings because you used the |
Why is this closed? We really need a better way to disable warnings or at least to disable the Experimental API warning |
You can just change your shebang to |
The
|
@jasnell one issue I just noticed is that that can't be set from within the program when it has already launched. |
@benjamingr, are you able to put it in the shebang? This worked for me:
|
This also worked for me: process.env.NODE_NO_WARNINGS = 1; |
@squallstar doesn't work for me. Which node version are you testing on? I'm testing |
@hexrcs the above works for me on Node 12. I have right before a |
Is this documented anywhere? I couldn't find anything about this env variable but it would certainly be great if we finally get this feature. :) |
@hexrcs https://nodejs.org/api/cli.html#cli_node_no_warnings_1 (or search for |
Weird, because setting it to either a string Just tested on node v12.13.0 using the example below, also doesn't seem to work. :(
If the node interpreter is spawned with |
@hexrcs I just tested on Node v12.13.0 and I am using Mac OS 10.15.2 (19C57), works great from here. |
@hexrcs something which you can try is to spawn a child process after the env variable has been updated. I remember doing that on previous versions of node when using commander to create a node-based CLI tool. |
@squallstar Thanks for the tip :) I've been doing similar things: OK, I just upgraded node to v12.14.1, also doesn't work... Way too weird. Anyway, I'll keep using the child process approach for now. |
I raised this same issue here (oops): #32876 and @sam-github kindly took the time to explain there's a solution using |
As an end-user, I don't want to ever see warnings or deprecations. However, when node is invoked from a shell script via a shebang, there is no opportunity to pass the
--no-warnings
option to the process.Is there an environment variable that can be set to toggle this option? If not, please add support for something like
NODE_NO_WARNINGS=1
.The text was updated successfully, but these errors were encountered: