Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS: add options to npmrc

Tags:

node.js

I am currently running my script as

node --no-deprecation main.js

I was wondering if there is a way to add this option to ~/.npmrc or otherwise (environment variable), such that I do not need to add the option to the command line. I would like to just run my script as node main.js and to be shown no deprecation warnings.

To make this question more general, is there a general way in NodeJS of setting flag values in a config file rather than adding it to the command (say I am interested in running with --trace-warnings as well.

I am looking for something cleaner than say alias node="node --no-deprecation".

I already tried adding this line inside ~/.npmrc

no-deprecationss=true

Reference: https://nodejs.org/dist/latest-v7.x/docs/api/cli.html#cli_no_deprecation

like image 965
Andrei Cioara Avatar asked Mar 03 '26 00:03

Andrei Cioara


1 Answers

If you're looking for a global configuration, setting the --no-deprecation flag in the NODE_OPTIONS environment variable in your .bashrc or other shell config file is what you're looking for, as long as you're using node v8 or above.

https://nodejs.org/docs/latest-v10.x/api/cli.html#cli_node_options_options

like image 166
topocount Avatar answered Mar 04 '26 14:03

topocount



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!