# 3js not recognized when within script file

**URL:** <https://discourse.threejs.org/t/3js-not-recognized-when-within-script-file/48245>\
**Category:** Questions\
**Tags:** script\
**Created:** [February 20, 2023, 10:26am UTC](https://discourse.threejs.org/t/3js-not-recognized-when-within-script-file/48245 "2023-02-20T10:26:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hermann](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hermann](https://discourse.threejs.org/u/hermann)\
**Post date:** [February 20, 2023, 10:26am UTC](https://discourse.threejs.org/t/3js-not-recognized-when-within-script-file/48245/1 "2023-02-20T10:26:14Z")

</div>

I am trying to install the latest version of 3js.

I go by the directions on the 3js website, here:  
[https://threejs.org/docs/index.html#manual/en/introduction/Installation](https://threejs.org/docs/index.html#manual/en/introduction/Installation)  
I am doing part: “Install from CDN or static hosting”.

I have downloaded the library onto my computer, so I am referring to my own file there.

Using this, I can run 3js code.

But the problem is, if I try to run that given code in it’s own file, like this:

> ```
> <script src="./thecode.js"></script>
> 
> ```

I get error:  
Uncaught ReferenceError: THREE is not defined

It is like it’s not recognizing threejs at all, in that file.  
But it recognises threejs, if I just keep it in the index.html.  
But I can’t just be programming in the index file forever.

How do I get it to recognize threejs in the file?

I have also tried adding type=“module”, to the reference, to no avail.
