# Errors when adding orbitalcontrols.js

**URL:** <https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603>\
**Category:** Questions\
**Tags:** getting-started\
**Created:** [September 5, 2021, 11:41am UTC](https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603 "2021-09-05T11:41:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratik\_Hadawale](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pratik_hadawale/32/20724_2.png) [@Pratik\_Hadawale](https://discourse.threejs.org/u/Pratik_Hadawale)\
**Post date:** [September 5, 2021, 11:41am UTC](https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603/1 "2021-09-05T11:41:02Z")

</div>

This is how i am linking files

```javascript
   <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/three-orbitcontrols@2.110.3/OrbitControls.js"></script>
    <script src="index.js"></script>

```

and this is how i am initializing orbital controls

```javascript
const orbitControl = new THREE.OrbitControls(camera, renderer.domElement);

```

and this is the error i am getting

```javascript
OrbitControls.js:1 Uncaught ReferenceError: require is not defined
    at OrbitControls.js:1
(anonymous) @ OrbitControls.js:1
index.js:85 Uncaught TypeError: THREE.OrbitControls is not a constructor
    at index.js:85

```

I tried everything i could but cannot resolve it. Please help!

---

<div class="post-metadata">

**Author:** ![Omar\_Shehata](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/omar_shehata/32/43576_2.png) [@Omar\_Shehata](https://discourse.threejs.org/u/Omar_Shehata)\
**Post date:** [September 6, 2021, 1:24am UTC](https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603/2 "2021-09-06T01:24:50Z")

</div>

This version of OrbitControls you are trying to include is meant to be used within an npm project, and not directly imported in a browser.

Try including this version instead: [https://unpkg.com/browse/three@0.132.0/examples/js/controls/OrbitControls.js](https://unpkg.com/browse/three@0.132.0/examples/js/controls/OrbitControls.js)

---

<div class="post-metadata">

**Author:** ![Pratik\_Hadawale](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pratik_hadawale/32/20724_2.png) [@Pratik\_Hadawale](https://discourse.threejs.org/u/Pratik_Hadawale)\
**Post date:** [September 6, 2021, 3:47am UTC](https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603/3 "2021-09-06T03:47:20Z")

</div>

Thanks for the reply i appreciate it, but it’s still producing an error

```javascript
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://unpkg.com/browse/three@0.132.0/examples/js/controls/OrbitControls.js with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
index.js:83 Uncaught TypeError: THREE.OrbitControls is not a constructor
    at index.js:83
(anonymous) @ index.js:83

```

It’s still producing those two errors, for the latter error i tried to remove the THREE. but still i produced a an error, something along the lines of “orbitcontrols is not defined”

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [September 6, 2021, 7:51am UTC](https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603/4 "2021-09-06T07:51:47Z")

</div>

Try it with these two imports:

```javascript
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/controls/OrbitControls.js"></script>

```

In general it makes no sense to import library files from different CDNs. And it’s definitely wrong to import `three.js` files from different releases.

---

<div class="post-metadata">

**Author:** ![Pratik\_Hadawale](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pratik_hadawale/32/20724_2.png) [@Pratik\_Hadawale](https://discourse.threejs.org/u/Pratik_Hadawale)\
**Post date:** [September 6, 2021, 8:03am UTC](https://discourse.threejs.org/t/errors-when-adding-orbitalcontrols-js/29603/5 "2021-09-06T08:03:21Z")

</div>

Thank You! It’s working again 🙂

I was trying to find cdn for the latest release but was having trouble, so i used the r128 version, but now i know that i should use the latest release and the same cdns
