I am running Sandbox module in my Node.JS application which runs dynamic scripts from my database. By default Sandbox blocks access to Node methods and anything else in the Master process. I am trying to figure out how to include libraries and methods that I choose.
The process ONLY runs the code that is in the sandbox.run() and built as a string.
I'm not sure about the Sandbox module, but you can use the VM module from node core. Start with creating a context and then use runInContext.
The module you're looking for is vm2. vm2 is a sandbox that can securly run untrusted code with whitelisted built-in node objects.