Really old question but...
I was looking for something similar, I believe, and found out this.
You can open the REPL (typing node
on your terminal) and then load a file.
Like this: .load ./script.js
.
Press enter and the file content will be executed. Now everything created (object, variable, function) in your script will be available.
For example:
// script.js
var y = {
name: 'obj',
status: true
};
var x = setInterval(function () {
console.log('As time goes by...');
}, 5000);
On the REPL:
//REPL
.load ./script.js
Now you type on the REPL and interact with the "living code".
You can console.log(y)
or clearInterval(x)
;
It will be a bit odd, cause "As time goes by..." keep showing up every five seconds (or so).
But it will work!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…