# Don't know how to import three.js in project : THREE is not defined

**URL:** <https://discourse.threejs.org/t/dont-know-how-to-import-three-js-in-project-three-is-not-defined/89228>\
**Category:** Questions\
**Created:** [January 18, 2026, 10:41am UTC](https://discourse.threejs.org/t/dont-know-how-to-import-three-js-in-project-three-is-not-defined/89228 "2026-01-18T10:41:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdelente](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@fdelente](https://discourse.threejs.org/u/fdelente)\
**Post date:** [January 18, 2026, 10:41am UTC](https://discourse.threejs.org/t/dont-know-how-to-import-three-js-in-project-three-is-not-defined/89228/1 "2026-01-18T10:41:57Z")

</div>

Hello,

I’m following the tutorial by Matthias Müller on Youtube, specifically [https://www.youtube.com/watch?v=j84zJ06wnVA](https://www.youtube.com/watch?v=j84zJ06wnVA)

In his videos, he imports three.js with

but the HTML file loads forever in Firefox, so I guess this way of doing is wrong.

I installed three.js in my project directory with ’npm install --save three’ and put in my HTML file this code:

 // scene ----- var threeScene; var renderer; var camera; var cameraControls; //simulation ----- function simulate() { } // ----- function initThreeScene() { threeScene = new THREE.Scene(); but either the page loads forever or I get a “THREE is not defined” error. I’m very new to npm and three.js, can anybody help me there? Thanks! F. Delente

---

<div class="post-metadata">

**Author:** ![trusktr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/trusktr/32/13726_2.png) [@trusktr](https://discourse.threejs.org/u/trusktr)\
**Post date:** [January 18, 2026, 11:45am UTC](https://discourse.threejs.org/t/dont-know-how-to-import-three-js-in-project-three-is-not-defined/89228/2 "2026-01-18T11:45:31Z")

</div>

The video shows the old way.

- Go to [https://generator.jspm.io](https://generator.jspm.io).
- Input “three” in the input box and hit enter.
- In the toolbar with the toggle switches, click on “[jspm.io](http://jspm.io)” and change it to “jsdelivr” (or not, you can test and choose the CDN that you prefer. JSDelivr supports GitHub URLs with commit hashes for versions, [for example](https://cdn.jsdelivr.net/gh/mrdoob/three.js@a470d32cdbdfe23399af3a237a9879f2614fb5d6/build/three.tsl.js))
- finally, you should see this piece of code:

```html
  <!--
    Import map generated with JSPM Generator
    Edit here: https://generator.jspm.io/#U21hZGBkDM0rySzJSU1hKMkoSk11MNAztDDSMwAAwygQfBwA
  -->
  <script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.module.js"
    }
  }
  </script>

```

Put that into your HTML file. In fact, you can see there that it shows you a sample HTML file that you can start with.

Next add your (module) script with your code to use `THREE`, like follows (type=“module” enables `import` syntax):

```html
<script type="module">
  import * as THREE from 'three'

  console.log( THREE.Scene )
</script>

```

You don’t have to put everything in `THREE`, you can import individually if you prefer:

```html
<script type="module">
  import { Scene } from 'three'

  console.log( Scene )
</script>

```

In total, the full HTML file may look like this:

```html
<html>
  <head>
    <!-- ... stuff like the title ... -->
  </head>

  <body>
    <!--
      Import map generated with JSPM Generator
      Edit here: https://generator.jspm.io/#U21hZGBkDM0rySzJSU1hKMkoSk11MNAztDDSMwAAwygQfBwA
    -->
    <script type="importmap">
    {
      "imports": {
        "three": "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.module.js"
      }
    }
    </script>

    <script type="module">
      import * as THREE from 'three'

      console.log( THREE.Scene )
    </script>
  </body>
</html>

```

The order of those two scripts matter. The `importmap` has to go before the `module`, or the `import` statement won’t find `three`.

If you see docs and example and you want to add more things like `three/webgpu`, `three/addons/...`, etc, you can
