What does VisitFunction error mean?

Running Node.js @ 0.8.15 + Express @ 3.0.4 + Jade @ 0.27.7 + Stylus @ 0.31.0. For some reason, the following error occurs. Does anyone know what that means?

I do not think that I am doing something strange. This happens when I do: 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) 
+4
source share
1 answer

One of the reasons why you might get this error is because you added new properties (usually methods) to Object.prototype

Example:

 Object.prototype.someNewMethod = function (value1, value2) { // ... perform some operations return this; }; 

This method of adding new properties to Object not recommended, as indicated in issue # 1033 for the express project. Object.defineProperty should be used instead of enumerable instead of false .

Example of extending Object using 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 Object.defineProperty problem using Object.defineProperty with enumerable:false to define new properties.

I hope this helps.

+6
source

All Articles