I am new to node.js and I’m just trying to learn how to use Express and Jade. It seems that this line in jade.js is causing some kind of problem: window.jade = require("jade");
I can start up my server just fine, but when I visit it in my browser I get this error:
ReferenceError: window is not defined
at C:\Users\User\Desktop\node-js-web\node_modules\jade\jade.js:3142:1
at Object.<anonymous> (C:\Users\User\Desktop\node-js-web\node_modules\jade\jade.js:3143:2)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (C:\Users\User\Desktop\node-js-web\node_modules\jade\index.js:4:5)
at Module._compile (module.js:441:26)
When I comment out that line I get this error instead:
TypeError: Object #<Object> has no method 'compile'
at Function.compile (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\view.js:68:33)
at ServerResponse._render (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\view.js:417:18)
at ServerResponse.render (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\view.js:318:17)
at C:\Users\User\Desktop\node-js-web\server.js:37:7
at callbacks (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\router\index.js:272:11)
at param (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\router\index.js:246:11)
at pass (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\router\index.js:253:5)
at Router._dispatch (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\router\index.js:280:4)
at Object.handle (C:\Users\User\Desktop\node-js-web\node_modules\express\lib\router\index.js:45:10)
at next (C:\Users\User\Desktop\node-js-web\node_modules\express\node_modules\connect\lib\http.js:203:15)
I really don’t know what to do here. Can anyone help?
There is no
windowobject in Node.js because it’s not in a browser. If you want to attachjadeto the global scope, useglobal.(But why do you want to make the variable global to your application, anyways? Only Express needs the jade object to render your views.)