JS Newb needs help

How can I use an stl file instead of the sphere in the barcode example from here ?

I downloaded the “STLLoader”.js from the offical page but i get an error :
Uncaught SyntaxError: Cannot use import statement outside a module (at STLLoader.js:1:1)

Any help is welcome.

you need webpack or rollup to import js module

Or use <script type="module"> if you’re loading it via a script tag.

Otherwise, bundling your code with vite, rollup, webpack etc is a good option.

three has an installation guide in the docs three.js docs i suggest you follow it.

prefer option 1 (vite), which also happens to be the simplest. as a general rule you can’t use npm modules without a tool like vite.

option 2, script module includes may occasionally work under certain conditions but it’s almost a broken specification at this point. it is very complicated and confusing, it will not work with most published packages because they rushed the spec.

Thanks for the infos, I will post later what I tried.

Im not trying to be difficult, just trying to understand but since in the stl loader example I can use local file and same for the ar example, I should be able to use local files for both in the same program.