2

When I type "node" in my cmd, I can write some js: enter image description here but when I run something ("node someapp.js") I can't. But I want to be able to type some js code while js code is running. It is possible? How to do that?

I'd like to access all variables that are created by runned program. The program creates function countToTen() and I will be able to execute this function from command line.

Piotrek
  • 10,919
  • 18
  • 73
  • 136
  • What would it mean to type some code while other code is running? Which code would run? Would you expect to be able to run two programs in a single interpreter also? If you just want to run one program in the "background", do `node someapp.js &` then run node again. – John Zwinck Mar 28 '14 at 11:24
  • I want to have access to all variables that exists in running nodejs program – Piotrek Mar 28 '14 at 11:26
  • Why would you want that? It completely open up your program and makes it incredibly insecure. – RB-Develop Mar 28 '14 at 12:29
  • You could require another program from within the Node REPL. For example type: fs = require('fs'); x = fs.readFileSynch('somefile.txt'); console.log(x); – Hector Correa Mar 28 '14 at 12:58
  • Possible duplicate of [How do I load my script into the node.js REPL?](http://stackoverflow.com/questions/8425102/how-do-i-load-my-script-into-the-node-js-repl) – LarsW Apr 08 '17 at 13:34

0 Answers0