Are you including your main js file from html?
In html, we mark them as a type=“module” to allow use of “import”
It looks like however it’s being included in your case, it’s not being marked as a module.
Hi manthrax
your solution worked but i have an other error.
check this
You need to configure the way you make your imports on the project. I suggest you install vite, install three and make the imports without the use of cdn. I had this issue many times and I solved using this approuch because it’s more simple.
- Install Vite
- Install Three
- Make the imports inside your main.js
- Ensure your on .HTML is with “type=module”
Hi , iHast
Sorry , But that’s only in Web. I am talking about apps and electron
Take a look a the official three installation docs, you have two options:
- Option 1: Install with NPM and a build tool.
- Option 2: Import from a CDN.
I think you’re using option 2, with apps and electron, you should follow Option 1, electron has its own build tools.
Oh! I see. Sorry man, my bad.
Did you try solve it using Cursor with Claude Sonnet?
Hi , Fennec
Yes , I am using the first option. But there is an error that i couldn’t solve.
Add to path / or ./ or …/
there is the code
<script type="module" src="./game.js"></script>
check paths into game.js
I checked it . It takes place in my folder and the path is correct
That’s not how the first option work, checkout this guide to see how to start a new vite project
You don’t need any <script>
, just import
I know . But , I am writing my JS code in an another file . That’s why I am using it to link JS file with HTML file