Can I open a shell prompt from within NodeJS?

186 Views Asked by At

I'm in a NodeJS command-prompt session and I want to dip out to shell for a few commands and come back to my session with variables intact.

I remember doing this as a kid using "!" in another environment - can I do something like that in Node?

1

There are 1 best solutions below

2
Hoshi On

I just remembered about Ctrl-z / fg. Ctrl-z makes the Node session a background process and leaves me in the shell (and pauses it - if I wanted it to keep running something I could use the bg command). Then fg puts me back into the Node environment.

This is probably close enough to what I was thinking about.

I'm open to other options though!