简体   繁体   中英

Node.js Global variables from 2 different scripts would they conflict?

For Node.js global variable, if i have a script running on port 3000, and another exact same script running on 3001, would the global variable conflict each other? Or if they are in totally different environment?

My situation is this, i have an AWS EC2 instance, and 2 script running on it, they are exactly the same script and both scripts has a lot of global variables like this global[version1data] so if i run both of the script, does would my data get corrupted as if they are running in the same script?

In you case they won't conflict because they are global per process. Think about the process , which is a global object, and within each Node.js app/program you can get different values for process.env , for example

Every time you run "node something.js", you are creating a new process with a different environment. So... no, the global variables will not conflict.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM