I wish to suspend a REPL session so that I could shut down the system and then at a later time continue to work on the REPL session as if I'd never closed it, i.e. without having to lose all the environment.

I think that the possible solutions to this could be 

1. **Snapshot memory, save to file and load env from file later**: I think this would be the neatest solution, like happens when you use the 'hibernate' feature of Windows. I've found this [heapdump](https://github.com/bnoordhuis/node-heapdump) utility which is intended to take a memory snapshot for analysis of memory leaks, but I don't know if you could resurrect the whole environment from that snapshot and I have found no tools that do so.
2. **Save commands and replay them**: A major shortcoming of this method is while it works for simple things like `var x = "Hello World";`, it wouldn't work for things like `var reciptId = bankAccount.makePayment(1000);` as it will repeat actions on each replay rather than saving the details of the original function call.
3. **Serialize / Deserialize the whole environment**: This would involve making a list of all objects that exist in the environment, and then make a mechanism to write each of them to a file i.e. serialize them, and then make a mechanism that deserializes these and loads them when required. I am yet to see a clean way to serialize and deserialize js variables without limitations. I think that the major limitation of this method is its inability to retain references, so the objects loose their class, things would have to be duplicated upon serialization and lose their equality on deserialization - e.g. 
`var f = function (x) {...}; 
var a = {};
a.f = f;
a.f === f? //is true, not true if your serialization mechanism saves a function defn for f and a.f separately and deserializes them separately`
and cyclic references would probably not work (`x = {}; x.cyclic = x;`...). So this method, if it ever works would require a lot of dirty work.

So the question really is, how difficult is it to achieve what I wish to achieve? What could be some other solutions to do this? Is there a major obstruction to achieving this which I'm overlooking?

Also, are there any alternatives to the node repl program (like a console in a browser) that *can* be suspended like this?

Related : 

* [Swift REPL: how to save/load the REPL state? (a.k.a. suspend/resume, snapshot, clone)](https://stackoverflow.com/questions/27872764/swift-repl-how-to-save-load-the-repl-state-a-k-a-suspend-resume-snapshot-c)