'require' is not defined in console tab of node-inspector's repl
问题 I tried to require('fs').writeFileSync('o.json', JSON.stringify(anObject)); for debugging, and I got RefrenceError: require is not defined. This is bizarre. What kind of an environment is it that doesn't have require ? 回答1: In Node.js, the require function is not defined globally. When you require a module, its source code is wrapped by a function that takes several arguments and require is one of them: (function (exports, require, module, __filename, __dirname) {/* your code */ }); You can