0

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?

user1944491
  • 559
  • 1
  • 8
  • 24

1 Answers1

0

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!

user1944491
  • 559
  • 1
  • 8
  • 24
  • Obviously, Ctl-Z/fg only works if you're in a *nix environment (like Linux). Another option might be [child_process](https://nodejs.org/api/child_process.html): https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a/. – paulsm4 Aug 12 '22 at 23:11
  • @paulsm4 that’s true and the article you linked is awesome but I was looking for a “built-in” command, not a programming sub-project. – user1944491 Aug 14 '22 at 03:39