facn2 / Week2-Ba6e5-Developers-TodoList

ToDoList
https://facn2.github.io/Week2-Ba6e5-Developers-TodoList/
2 stars 1 forks source link

module.exports in browser #42

Open m4v15 opened 7 years ago

m4v15 commented 7 years ago

Bit harsh, as we've been telling you to use this, but it's good to know - module.exports is actually a node.js thing and throws an error in the browser -

logic.js:80 Uncaught ReferenceError: module is not defined
    at logic.js:80

You can get around this by checking if module is defined in the environment in which the code is running (it is defined in node, but not in the browser)

if (typeof module !== 'undefined') {
  module.exports = todoFunctions;
}

Useful link