Skip to content

Instantly share code, notes, and snippets.

@PenneyGadget
Forked from rrgayhart/require.markdown
Last active April 2, 2016 19:30
Show Gist options
  • Save PenneyGadget/2dc5becb5c371a848675ae77d7e54ca0 to your computer and use it in GitHub Desktop.
Save PenneyGadget/2dc5becb5c371a848675ae77d7e54ca0 to your computer and use it in GitHub Desktop.
The Concept of Require

When you start working with WebPack for GameTime, you'll notice that you can't just define a variable in one file and find it in another as easily as you can in Rails.

Read Node.js, Require and Exports and Organize Your Code with RequireJS

Fork this gist and answer the following questions:

  • In the context of Node, what is a module?

It's essentially a file - very similar to a class in Ruby. A file corresponds to a module and everything within that file/module is private. We have to export the module and then require it in the other file where we want to use it.

  • The code examples from the second blog post look very different from the first. Why?

The second blog post is using RequireJS and the define call instead of module.exports from CommonJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment