Safe secure Sandboxed VM for code.
const safevm = require('safevm');
result = safevm( // result is the module.exports
function () {
output("test");
},
// string or function of code to be run safely
[{ output: console.log }],
// array of context/globals, default use is the first or a new object
{ filename: "" }
// Options from https://nodejs.org/api/vm.html#vm_vm_runinnewcontext_code_sandbox_options with a few added options like dirname, globalIndex, onError, etc.
);
result = safevm(require("fs").readFileSync("path/to/file.js"), {}, { filename: "vm.js"});