# Can't run html files in Chrome locally

**URL:** <https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746>\
**Category:** Questions\
**Tags:** dev-tools\
**Created:** [February 14, 2020, 4:21pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746 "2020-02-14T16:21:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyanBuck](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@RyanBuck](https://discourse.threejs.org/u/RyanBuck)\
**Post date:** [February 14, 2020, 4:21pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/1 "2020-02-14T16:21:08Z")

</div>

I normally use Chrome for browsing and the [threejs.org](http://threejs.org) site runs fine there. I’ve been experimenting with three.js for the past few weeks, using various examples from the master.zip and tinkering with them, but when I ran all my tests they opened in Microsoft Edge by default. I didn’t question it; I have tons of tabs open in Chrome as it is, so it was nice to have a separate browser for viewing my progress. I got to a point where I was ready to show things to my coworkers and they couldn’t view it. That’s when I noticed it doesn’t work in Chrome.

Further tests showed that none of the example html files from the master.zip appeared to work in Chrome. They run perfectly on [threejs.org](http://threejs.org), but not when the downloaded copies are run locally. Does anyone have any advice on how to fix this?

I’m running Windows 10  
Microsoft Edge is v 44.18362.449.0  
Chrome is v 80.0.3987.106

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [February 14, 2020, 5:01pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/2 "2020-02-14T17:01:11Z")

</div>

When you say “running locally” what do you mean? Are you clicking the HTML files and opening them in the browser? Or using a local server? What errors do you see in Chrome’s JS console?

Resources like images cannot be opened by browsers from `file://` URLs. This is a browser security security requirement, not a library limitation. It’s necessary to run a local server of some kind, with several options listed at [https://threejs.org/docs/#manual/en/introduction/How-to-run-things-locally](https://threejs.org/docs/#manual/en/introduction/How-to-run-things-locally).

---

<div class="post-metadata">

**Author:** ![Hoodgail\_Benjamin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hoodgail_benjamin/32/20769_2.png) [@Hoodgail\_Benjamin](https://discourse.threejs.org/u/Hoodgail_Benjamin)\
**Post date:** [February 14, 2020, 5:08pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/3 "2020-02-14T17:08:33Z")

</div>

i needle to create a localhost server  
you can use the following

> **[Web Server for Chrome](https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en)**
>
> A Web Server for Chrome, serves web pages from a local folder over the network, using HTTP. Runs offline.

> **[Node.js](https://nodejs.org/en/)**
>
> Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

or any other

---

<div class="post-metadata">

**Author:** ![RyanBuck](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@RyanBuck](https://discourse.threejs.org/u/RyanBuck)\
**Post date:** [February 14, 2020, 5:24pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/4 "2020-02-14T17:24:27Z")

</div>

Thank you both for the responses. I did not realize a server was necessary. Not sure why it worked in Edge without any issues. I’d never used the browser before.

---

<div class="post-metadata">

**Author:** ![rrrr\_rrrr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/rrrr_rrrr/32/7697_2.png) [@rrrr\_rrrr](https://discourse.threejs.org/u/rrrr_rrrr)\
**Post date:** [February 15, 2020, 1:52pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/5 "2020-02-15T13:52:54Z")

</div>

RyanBuck wrote: I did not realize a server was necessary.  
Not necessary. but it is the best choice.

RyanBuck wrote: Not sure why it worked in Edge.  
It shouldn’t, most likely will be removed in future releases.

RyanBuck wrote: Further tests showed that none of the example html files from the master.zip appeared to work in Chrome. They run perfectly on [threejs.org](http://threejs.org), but not when the downloaded copies are run locally. Does anyone have any advice on how to fix this?

You need an older version of 3JS before she went modular ( 103 ).

For Chrome 80:  
Create a shortcut to chrome.exe and rename it.  
Right click shortcut, click on “Properties”, select “Target” ( highlighted ).  
Append " --allow-file-access-from-files" without quotes to “Target”,  
Click on “Apply” then “OK”.

The “Target” on my machine is:  
“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” --allow-file-access-from-files

Close all instances of Chrome or this will fail.  
Double check with taskmgr.exe, “Applications” & “Processes” tab MUST BE chrome free.  
Now click on the modified shortcut and load your file.

As long as that window of chrome.exe is not closed, JS has access to ALL files accessible to Chrome.

For FireFox 72:  
Goto about:config ( addressbar ) and click on “Accept the Risk and Continue” ( if is visible )  
Enter “privacy.file\_unique\_origin” without quotes in search text box.  
Change “privacy.file\_unique\_origin” from true to false.  
Restart FF.

Now JS has access to the working directory and sub.

PLEASE note, these methods may result in security vulnerability, depending on your discipline and browser habits.  
Another words DO NOT open local html files downloaded from untrusted source with these settings.

---

<div class="post-metadata">

**Author:** ![Green\_Nights](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/green_nights/32/12370_2.png) [@Green\_Nights](https://discourse.threejs.org/u/Green_Nights)\
**Post date:** [April 11, 2021, 9:49pm UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/6 "2021-04-11T21:49:16Z")

</div>

In the run command,  
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --allow-file-access-from-files

Is how I developed my project, but the module examples don’t run. for example:  
file:///C:/ftp/cwebgl/threejs/examples/webgl\_materials\_cubemap\_dynamic.html

How to run these module imports without error: Failed to load module script: The server responded with a non-JavaScript MIME type of “”. Strict MIME type checking is enforced for module scripts per HTML spec.

ADD THIS

```javascript
 <script src="../build/three.js"></script>

```

///import \* as THREE from ‘…/build/three.module.js’;

But other imports I cannot correct.  
Why is it doing this, can anyone fix this?  
Regardless any “Security” setting chosen.

---

<div class="post-metadata">

**Author:** ![hofk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hofk/32/44944_2.png) [@hofk](https://discourse.threejs.org/u/hofk)\
**Post date:** [April 12, 2021, 7:10am UTC](https://discourse.threejs.org/t/cant-run-html-files-in-chrome-locally/12746/7 "2021-04-12T07:10:19Z")

</div>

Please read that. 🙂

[three.js docs](https://threejs.org/docs/index.html#manual/en/introduction/How-to-run-things-locally)  
[Module Import / Usage - #18 by looeee](https://discourse.threejs.org/t/module-import-usage/11574/18)

From the [Collection of examples from discourse.threejs.org](https://discourse.threejs.org/t/collection-of-examples-from-discourse-threejs-org/4315)

[\* discourse.threejs.hofk.de](https://hofk.de/main/discourse.threejs/) ![2021-04-04 10.14.09](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/2/1/21fa3d8a25e401ccce2818810d1e1944e84c90e6.png)

and have a look to [BeginnerExample](https://hofk.de/main/discourse.threejs/BeginnerExample/BeginnerExample.html)
