Sunday, 2 April 2017

Browserify document is undefined

i just found browserify, which sounds really cool. However i try to append a canvas element to the body(filename : Renderer.js):

  window.document.body.appendChild(this.canvas)
  module.exports = Renderer

And i also have a main.js

var Renderer = require("Renderer.js")
var r = new Renderer();

So i build the bundle like this:

browserify main.js -o bundle.js

And when i start the project:

node server.js

I get the following error message

  • ReferenceError : document is not defined (if only document.body)
  • And window is not defined (when window.document.body)

Can someone explain this behaviour and how to fix it?



via lolio

No comments:

Post a Comment