直接x=require(http).createServer.listen的话,哪怕是全局变量也只存在于那个进程中。再次打开node.exe是一个新的进程,变量不存在。请教一旦关了命令行界面,如何才能再访问当时启动的上下文去热操作那个x?总不能每次都重启吧
人生最曼妙的风景,竟是内心的淡定与从容!
Global variables only exist in one process and cannot be called across processes. If you want to debug, write it directly in the js file. After modification, you can only restart. js is a 'semi-compiled' language.
Used under linuxnohup node xxxx.js &Used under windowsstart node xxx.js
nohup node xxxx.js &
start node xxx.js
Configuration like this can be done not in global variables, but in the file system
Global variables only exist in one process and cannot be called across processes. If you want to debug, write it directly in the js file. After modification, you can only restart. js is a 'semi-compiled' language.
Used under linux
nohup node xxxx.js &
Used under windows
start node xxx.js
Configuration like this can be done not in global variables, but in the file system