Hello, community!
I am trying to use phaser with nodejs, but I am getting this error: Cannot use import statement outside a module
here is my HTML and css and js code and file structure:
Hello, community!
I am trying to use phaser with nodejs, but I am getting this error: Cannot use import statement outside a module
here is my HTML and css and js code and file structure:
I dont know that much but Mabey it because “Phaser uses the ECMAScript Modules (ESM) module system, while Node.js uses the CommonJS module system by default. The error “Cannot use import statement outside a module” occurs because you are trying to use the import
statement, which is part of the ESM module system, in a file that is using the CommonJS module system.”
I doubt thats it
It’s probably that actually.
Try adding a "type": "module"
property to package.json
.
I don’t think that you can use Phaser in NodeJS, you have to use a browser.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.