Node.js error "ReferenceError: global is not defined" after updating from 0.10.2 to 0.12.2

Node.js error "ReferenceError: global is not defined" after updating from 0.10.2 to 0.12.2

以下代码用于在使用 Node.js 并重定向控制台的服务器上执行沙盒 JavaScript 代码。

在我们将版本从 Node.js 0.10.2 更新到 Node.js 0.12.2

之前,它起到了很好的作用
var EOL = require('os').EOL;

DataView = undefined;
DTRACE_NET_SERVER_CONNECTION = undefined;
// DTRACE_NET_STREAM_END = undefined;
DTRACE_NET_SOCKET_READ = undefined;
DTRACE_NET_SOCKET_WRITE = undefined;
DTRACE_HTTP_SERVER_REQUEST = undefined;
DTRACE_HTTP_SERVER_RESPONSE = undefined;
DTRACE_HTTP_CLIENT_REQUEST = undefined;
DTRACE_HTTP_CLIENT_RESPONSE = undefined;
COUNTER_NET_SERVER_CONNECTION = undefined;
COUNTER_NET_SERVER_CONNECTION_CLOSE = undefined;
COUNTER_HTTP_SERVER_REQUEST = undefined;
COUNTER_HTTP_SERVER_RESPONSE = undefined;
COUNTER_HTTP_CLIENT_REQUEST = undefined;
COUNTER_HTTP_CLIENT_RESPONSE = undefined;
global = undefined;
process.argv = undefined;
process.versions = undefined;
process.env = { NODE_DEBUG: false };
process.addListener = undefined;
process.EventEmitter = undefined;
process.mainModule = undefined;
process.removeListener = undefined;
process.config = undefined;
// process.on = undefined;
process.openStdin = undefined;
process.chdir = undefined;
process.cwd = undefined;
process.umask = undefined;
GLOBAL = undefined;
root = undefined;
setTimeout = undefined;
setInterval = undefined;
clearTimeout = undefined;
clearInterval = undefined;
setImmediate = undefined;
clearImmediate = undefined;
module = undefined;
require = undefined;
msg = undefined;

delete DataView;
delete DTRACE_NET_SERVER_CONNECTION;
// delete DTRACE_NET_STREAM_END;
delete DTRACE_NET_SOCKET_READ;
delete DTRACE_NET_SOCKET_WRITE;
delete DTRACE_HTTP_SERVER_REQUEST;
delete DTRACE_HTTP_SERVER_RESPONSE;
delete DTRACE_HTTP_CLIENT_REQUEST;
delete DTRACE_HTTP_CLIENT_RESPONSE;
delete COUNTER_NET_SERVER_CONNECTION;
delete COUNTER_NET_SERVER_CONNECTION_CLOSE;
delete COUNTER_HTTP_SERVER_REQUEST;
delete COUNTER_HTTP_SERVER_RESPONSE;
delete COUNTER_HTTP_CLIENT_REQUEST;
delete COUNTER_HTTP_CLIENT_RESPONSE;
delete global;
delete process.argv;
delete process.versions;
delete GLOBAL;
delete root;
delete setTimeout;
delete setInterval;
delete clearTimeout;
delete clearInterval;
delete setImmediate;
delete clearImmediate;
delete module;
delete require;
delete msg;

var content = '';
process.stdin.resume();
process.stdin.on('data', function(buf) { content += buf.toString(); });
process.stdin.on('end', function() {
    var inputData = content.trim().split(EOL);
    var result = code.run(inputData);
    if (result !== undefined) {
        console.log(result);
    }
});

var code = {
    run: function Solve(args) {
        console.log('works');
    }
};

现在代码抛出异常:

util.js:67
if (isUndefined(global.process)) {
                ^
ReferenceError: global is not defined
    at Object.exports.deprecate (util.js:67:19)
    at net.js:1414:34
    at NativeModule.compile (node.js:805:5)
    at NativeModule.require (node.js:774:18)
    at tty.js:23:11
    at NativeModule.compile (node.js:805:5)
    at Function.NativeModule.require (node.js:774:18)
    at process.stdin (node.js:533:34)
    at Object.<anonymous> (C:\Program Files\nodejs\test.js:75:8)
    at Module._compile (module.js:460:26)

我的第 75 行是:

process.stdin.resume();

问题是否与过程变量有关,如果是,我如何 read/write 在 Node.js 0.12.2 中使用 stdin/stdout?

此外,如果问题出在 process.stdin.resume(); 上,我如何使用 Node.js 0.12.2 获得相同的结果?

编辑

documentation所说

The process object is a global object and can be accessed from anywhere.

这更令人困惑,因为异常是 ReferenceError: global is not definedprocess.stdin.resume();

global = undefined;

delete global;

不要那样做。