cpu_sam Posted May 20, 2018 Share Posted May 20, 2018 Hello, so, I was here reading and reading and reading and studying codes a lot and I can't resolve a simple problem: how to make a little example with Phaser 3. when I try to import Phaser as a module with the command: import * as Phaser from "./phaser3.8.0.js"; It gives me the follow error: Quote SyntaxError: import declarations may only appear at top level of a module But the import is already on top level of main module. Or even if I try to import my Player classe with the following: import Player from "./myPlayer.js"; Where myPlayer.js is the class file with a extends of Player with Phaser.GameObjects.Sprite. Link to comment Share on other sites More sharing options...
wclarkson Posted May 23, 2018 Share Posted May 23, 2018 I wouldn't try importing the Phaser library. Just link it in the HTML file and you'll be good to go. Link to comment Share on other sites More sharing options...
cpu_sam Posted May 23, 2018 Author Share Posted May 23, 2018 I abandoned ES 6 and now I use pure Typescript 2, thanks for the attention. Link to comment Share on other sites More sharing options...
kailcor Posted November 3, 2018 Share Posted November 3, 2018 I got that error too. The reason is, that you have to tell the browser that the script is an module with the attribute type. Something like this: <script src="index.js" type="module"></script> Link to comment Share on other sites More sharing options...
Recommended Posts