patriksimek / vm2

Advanced vm/sandbox for Node.js
MIT License
3.86k stars 293 forks source link

vm.run is not returning values #510

Closed ImLunaHey closed 1 year ago

ImLunaHey commented 1 year ago

Taken from the README, am I missing a step?

I'm using node v18.

const {NodeVM} = require('vm2');
const vm = new NodeVM();

const number = vm.run('1337'); // should return 1337

// This always returns failure
if (number === 1337) {
    console.log('success');
} else {
    console.log('failure');
}