JASON icon indicating copy to clipboard operation
JASON copied to clipboard

ReferenceError: require is not defined

Open yocontra opened this issue 12 years ago • 0 comments

var obj = {
  fn: function(url, cb) {
    require('http').get({
      host: url
    }, cb);
  }
};
var str = JASON.stringify(obj);
console.log(str);
var newobj = JASON.parse(str);

yields

{"fn":(function (url, cb) {
          require('http').get({
            host: url
          }, cb);
        })}

undefined:2
          require('http').get({
          ^
ReferenceError: require is not defined
    at eval at parse (/home/codex/apps/thread/node_modules/JASON/index.js:276:12)

I read the README section about this and it says items in the global scope (like require) should work. Am I doing something wrong here?

yocontra avatar Apr 24 '12 04:04 yocontra