joa*_*him 5 environment-variables node.js
是否可以在已加载并启动的 NodeJS 进程中注入/更改当前环境变量?
Exposing an Interface within the application is not an option, restarting is also not a valid option.
The process is running inside a docker container, requiring a specific NodeJS Version is possible.
EDIT: The change must be done from outside the application source so doing process.env.ENV_VAR = "new env" is not possible.
无法修改正在运行的进程的环境变量。这不是 NodeJS 进程独有的。这就是 env vars 在 UNIX 等操作系统上的工作方式。变量位于进程的地址空间内。虽然它们通常最初放置在靠近堆栈顶部的众所周知的位置,但当前的变量可能位于堆中的任意地址。环境变量是有意为每个进程私有的。因此,除非程序提供用于更改其环境变量的 API,否则一旦程序运行,您就无法修改它们。
| 归档时间: |
|
| 查看次数: |
2317 次 |
| 最近记录: |