Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify node process environment or arguments runtime

Tags:

node.js

Is it possible to modify process?

For example process.argv.push('something')?

It seems like other modules do not pick up the changes in the arguments.

I want to "trick" another module into acting like some argument was specified when the process was started.

Is process instantiated for each module on load and therefore globally immutable?

like image 995
Kenneth Lynne Avatar asked Jul 11 '15 20:07

Kenneth Lynne


People also ask

Can environment variables change at runtime?

Even if you change enviroment variable at run time the value will chnage but that change value will not be picked.

What is Node.js runtime environment?

The Node. js runtime is the software stack responsible for installing your web service's code and its dependencies and running your service. The Node.js runtime for App Engine in the standard environment is declared in the app.yaml file: Node.js 16.

How do you set a node environment to production?

You can signal Node. js that you are running in production by setting the NODE_ENV=production environment variable. in the shell, but it's better to put it in your shell configuration file (e.g. . bash_profile with the Bash shell) because otherwise the setting does not persist in case of a system restart.


1 Answers

You can modify process, just make sure that you do it before anything that is dependant on it loads and parses it.

like image 134
Kenneth Lynne Avatar answered Nov 14 '22 21:11

Kenneth Lynne