I need help so badly

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:
image


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

2 Likes

It’s probably that actually.

3 Likes

Try adding a "type": "module" property to package.json.

3 Likes

I don’t think that you can use Phaser in NodeJS, you have to use a browser.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.