Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Node VM run in context

node v10.24.1
version: 3.0.0
endpointsharetweet
// create 'myglobal' in global space: (function(){myglobal='my global'})() // access myglobal from eval - works eval("console.log('1 myglobal='+myglobal)") const vm = require('vm') const script = new vm.Script("console.log('2 myglobal='+myglobal)"); // run script in the global context - works script.runInThisContext() // run the same script in a new context - fails: script.runInNewContext()
Loading…

no comments

    sign in to comment