Running Node.js@0.8.15 + Express@3.0.4 + Jade@0.27.7 + Stylus@0.31.0. For some reason getting the following error. Does anybody know what this means?
I don't think I am doing anything weird. This is occurring when I am doing: res.render(view, response);
Property 'visitFunction' of object #<Object> is not a function
at Object.Compiler.visitNode (/app/node_modules/jade/lib/compiler.js:176:32)
at Object.Compiler.visit (/app/node_modules/jade/lib/compiler.js:161:10)
at Object.Compiler.visitBlock (/app/node_modules/jade/lib/compiler.js:253:12)
at Object.Compiler.visitNode (/app/node_modules/jade/lib/compiler.js:176:32)
at Object.Compiler.visit (/app/node_modules/jade/lib/compiler.js:161:10)
at Object.Compiler.compile (/app/node_modules/jade/lib/compiler.js:78:10)
at parse (/app/node_modules/jade/lib/jade.js:101:23)
at Object.exports.compile (/app/node_modules/jade/lib/jade.js:163:9)
at Object.exports.render (/app/node_modules/jade/lib/jade.js:215:17)
at View.exports.renderFile [as engine] (/app/node_modules/jade/lib/jade.js:243:13)
One of the reasons why you may get that error is because you added new properties (usually methods) to Object.prototype
Example:
Object.prototype.someNewMethod = function (value1, value2) {
// ... perform some operations
return this;
};
That way of adding new properties to Object is not recommended as stated in issue #1033 for express project. Object.defineProperty should be used with enumerable set to false instead.
Example of extending Object with Object.defineProperty
Object.defineProperty(
Object.prototype,
'someNewMethod',
{
writable : false,
// Will not show up in enumerable properties (including for-in loop).
enumerable : false,
configurable : false,
value : function (value1, value2) {
// ... perform some operations
return this;
}
}
);
I had exactly the same problem and using Object.defineProperty with enumerable:false to define new properties resolved the issue.
I hope that will help.