6

So when importing an external module like so

import GameObjects = module("GameObjects") 

the outputed JS has this at the top of the file:

var GameObjects = require("./GameObjects") 

but gives this error when run in chrome:> Uncaught ReferenceError: require is not defined

how do I get by this error?

2 Answers 2

8

External modules require a module loader to be present. If you run this in your browser you have to take care of including a module loader yourself. Please take a look at require.js, it has all the documentation that's needed to get the module loader running.

Sign up to request clarification or add additional context in comments.

1 Comment

I would have thought Microsoft would have automatically wired that up in the project :(
-1

If you want to use the built-in Microsoft solution, then replace your import with Triple Slashes.

So instead of import GameObjects = module("GameObjects"), you do /// <reference path="./Gameobjects.ts" /> at the top of the file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.