From 4d0f88277403b78d029d81b12186df422e664bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Becheras?= Date: Mon, 28 Nov 2016 12:29:18 +0100 Subject: [PATCH] fix #20 - add a workaround for undefined export var --- node/ltnodeclient.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/ltnodeclient.js b/node/ltnodeclient.js index cebc92a..fe61e9d 100644 --- a/node/ltnodeclient.js +++ b/node/ltnodeclient.js @@ -93,10 +93,12 @@ function sbRequire(require, resolve, path) { if(!getSB(path)) { if(path.match(/[\\\/]/) && fpath.extname(path) == ".js") { var sb = sandboxes[path.toLowerCase()] = context(path); + var _cleanCode = cleanCode(fs.readFileSync(path)); + _cleanCode = ';var exports = module.exports;' + _cleanCode; moduleCache[path] = sb.module; prevModule = currentModule; currentModule = sb.module; - vm.runInContext(cleanCode(fs.readFileSync(path)), sb, path); + vm.runInContext(_cleanCode, sb, path); currentModule = prevModule; sb.module.loaded = true; } else {