Loading STL file in THREE js

I’ve seen many threads here discussing this issue, simply put I can’t for the life of me import an STL Loader. I’ve tried many variations of
import { STLLoader } from ‘./STLLoader.js’;
but I can’t bypass “does not provide an export named”

I’ve tried using both js and jsm STL loader files but I’m too inexperienced to understand this issue.
And yes I have seen this example: three.js/webgl_loader_stl.html at 06160137744f186ad968a95f1eed450e85f7be2f · mrdoob/three.js · GitHub
but the only difference with my implementation is the file location. Which of course shouldn’t be an issue.

If you want to use ES6 import syntax, you have to use the jsm version of STLLoader. Depending on how you implement your project, you need an import map so modules like STLLoader are able to resolve the three module specifier.

It’s also important that you don’t import modules from different locations. So consider to import VTKLoader, Stats and STLoader from unpkg, too.

For a more robust workflow, consider to use the npm package of three and a build e.g. via rollup (see GitHub - Mugen87/three-jsm: Minimal three.js project setup using ES6 modules and rollup.)

Huge thanks I was able to load it with jsm version