Uncaught ReferenceError: exports is not defined
See original GitHub issueHi to everyone here, I’m new at phaser editor. I code in Typescript. I want to create a class and import it in level.ts. Bu I got “Uncaught ReferenceError: exports is not defined” message at browser’s console. My code is this: `///<reference path="ShapeControllerHTMLV1.ts" />
import { shapeController } from “./ShapeControllerHTMLV1”;
class Level extends Phaser.State {
constructor() {
super();
}
init() {
this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
this.scale.pageAlignHorizontally = true;
this.scale.pageAlignVertically = true;
}
preload () {
this.load.pack('section0', 'assets/pack.json');
}
create() {
var a = new shapeController.Greeter(this.game, 10, 10, 'blabla');
}
}And this is my class:export namespace shapeController{
export class Greeter extends Phaser.Sprite{
constructor(gm:Phaser.Game, _x:number, _y:number, _name:string){
super(gm, _x, _y, _name);
}
}
}`
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Typescript ReferenceError: exports is not defined
I had the error "exports is not defined" coming from an imported NPM module. Changing my typescript config did nothing as I had...
Read more >How to fix ReferenceError: exports is not defined TypeScript
If you are getting the error for code that runs in the browser, try defining a global exports variable above the script tags...
Read more >Uncaught ReferenceError: exports is not defined : r/typescript
Getting this error for some dumb reason i'm sure. Uncaught ReferenceError: exports is not defined. at app.js:2. (anonymous) @ app.js:2. all ...
Read more >exports is not defined" in browser : WEB-26773 - YouTrack
Typescript compiler outputs wrong javascript module format, giving "ReferenceError: exports is not defined" in browser ; "use strict"; Object.defineProperty ...
Read more >Uncaught ReferenceError: exports is not defined #27 - GitHub
When I try to import I get the Uncaught ReferenceError: exports is not defined . I've tried several solutions found on Stackoverflow and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok, look this answer here:
https://stackoverflow.com/questions/43472778/typescript-exports-is-not-defined
It is as I said in the last comment. If you want to avoid that exception:
Note if you use the second option you have to load all the js files in your
index.htmlfile or asscriptassets in theassets-pack.jsonfile.I am looking this. It think when you use import/export the target module system should support it. For example, you should include commonjs in your project. I have not too much experience with TypeScript, let me do a litte more research.
Thanks for send the project, it is helping a lot.