# Missing Dependencies

**URL:** <https://forum.needle.tools/t/missing-dependencies/2216>\
**Category:** 🌵 Needle Engine\
**Tags:** question\
**Created:** [January 29, 2025, 10:19am UTC](https://forum.needle.tools/t/missing-dependencies/2216 "2025-01-29T10:19:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_K](https://forum.needle.tools/user_avatar/forum.needle.tools/m_k/32/3643_2.png) [@M\_K](https://forum.needle.tools/u/M_K)\
**Post date:** [January 29, 2025, 10:19am UTC](https://forum.needle.tools/t/missing-dependencies/2216/1 "2025-01-29T10:19:29Z")

</div>

Annoyingly, a demo no longer works. I then upgraded to the current Needle version. The errors remain. Can you please help me solve the problem? Thanks.

 ![image](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/3/3e38aafec7c43e8a24e6185c38560eaa6e69a993.png)  
 ![image](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/8/8592a323a24af46d664d3bf08f049f29747f392b.png)  
 ![image](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/d/d3c7e140a6ad51c970a5a561f27016b6c5c2fa8f.png)  
 ![image](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/2/2b3ce38cbbef73c6835798a2ae83c1ba16c363ac.png)

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [January 29, 2025, 10:19am UTC](https://forum.needle.tools/t/missing-dependencies/2216/2 "2025-01-29T10:19:32Z")

</div>

Hi Matthias,

The errors you’re encountering related to “Missing Dependencies” can often arise after updates if the project references were not properly updated. Here are a few steps to help troubleshoot and resolve your issues:

1. **Update Dependencies** : Ensure all dependencies referenced in `package.json` are resolved correctly. Check that all npm definitions are valid and exist in your project. Missing npm definitions can lead to errors.

2. **Check for Existing GUIDs** : If any packages are missing, they might not have the correct GUID associated with them. Look for missing dependencies in your `ExportInfo` object and make sure their GUIDs are set appropriately.

3. **Installation** : It’s important to run `npm install` to ensure all packages are installed correctly. You may need to clean the `node_modules` directory and run `npm install` again if there was any corruption.

4. **Error Logs** : Check the Console logs for specific errors. If there are messages indicating a failed installation or missing paths, these can guide you on what needs to be fixed.

5. **Package Paths** : If you’ve moved any package files or renamed folders, make sure your project references point to the new locations. Use the functions provided in your files (like `Install` methods on dependencies) to update paths accordingly ([see the documentation](https://docs.needle.tools)) ([see the documentation](https://docs.needle.tools)).

In the provided code snippets, functions like `Install` and `EnsureDependenciesAreAddedToPackageJson` are essential for checking and installing missing packages.

If the problem persists even after these checks, providing more specific error messages or the content of the `package.json` file could help in diagnosing the issue further.

Let me know how it goes, and if you need further assistance!

_1 replies left_ - **[Get a PRO license](https://needle.tools/pricing)** for more AI replies.  
_thread\_iYEMAglmYkAyp1IwuEVqIhtE_  
_Reply to this message to continue the conversation_

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [January 29, 2025, 10:21am UTC](https://forum.needle.tools/t/missing-dependencies/2216/3 "2025-01-29T10:21:58Z")

</div>

Hello Matthias,

can you share more info. What does the browser console error show?

---

<div class="post-metadata">

**Author:** ![M\_K](https://forum.needle.tools/user_avatar/forum.needle.tools/m_k/32/3643_2.png) [@M\_K](https://forum.needle.tools/u/M_K)\
**Post date:** [January 29, 2025, 10:23am UTC](https://forum.needle.tools/t/missing-dependencies/2216/4 "2025-01-29T10:23:30Z")

</div>

> [@Marcel\_Wiessler1](#):
>
> ou share more info. What does the browser console error show?

 ![image](https://europe1.discourse-cdn.com/flex006/uploads/needle1/original/2X/c/c0ff61da99f8daa515d1da9d21fd0700b2863357.png)

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [January 29, 2025, 10:24am UTC](https://forum.needle.tools/t/missing-dependencies/2216/5 "2025-01-29T10:24:22Z")

</div>

Can you share the RBChangePositionOnClick script / imports? The error reads like you tried to import a script from a path/directory that is not exported.

---

<div class="post-metadata">

**Author:** ![M\_K](https://forum.needle.tools/user_avatar/forum.needle.tools/m_k/32/3643_2.png) [@M\_K](https://forum.needle.tools/u/M_K)\
**Post date:** [January 29, 2025, 10:28am UTC](https://forum.needle.tools/t/missing-dependencies/2216/6 "2025-01-29T10:28:49Z")

</div>

Ah, ich sehe da einen Fehler im Script. Zeile 141

```ts
import { ActionBuilder, BehaviorModel, Behaviour, GameObject, IPointerClickHandler, ObjectRaycaster, PointerEventData, TriggerBuilder, UsdzBehaviour, getWorldPosition, getWorldQuaternion, getWorldScale, isDevEnvironment, serializable, setWorldPosition, setWorldQuaternion, setWorldScale } from "@needle-tools/engine";
import { Space } from "@needle-tools/engine/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder";
import { Object3D, Vector3, Quaternion, Raycaster } from "three";

// Documentation → https://docs.needle.tools/scripting

function ensureRaycaster(obj: GameObject) {
    if (!obj) return;
    if (!obj.getComponentInParent(Raycaster)) {
        if (isDevEnvironment()) console.warn("Create Raycaster on " + obj.name + " because no raycaster was found in the hierarchy")
        obj.addNewComponent(ObjectRaycaster);
    }
}

export class RRChangePositionOnClick extends Behaviour implements UsdzBehaviour {

        @serializable(Object3D)
        object?: Object3D;
    
        @serializable(Object3D)
        target?: Object3D;
    
        @serializable()
        duration: number = 1;
    
        @serializable()
        relativeMotion: boolean = false;
    
        private coroutine: Generator | null = null;
    
        private targetPos = new Vector3();
        private targetRot = new Quaternion();
        private targetScale = new Vector3();
    
        start(): void {
            ensureRaycaster(this.gameObject);
        }
    
        onClicked() {
            if (this.coroutine) this.stopCoroutine(this.coroutine);
            if (!this.relativeMotion)
                this.coroutine = this.startCoroutine(this.moveToTarget());
            else
                this.coroutine = this.startCoroutine(this.moveRelative());
        }
    
        private *moveToTarget() {
    
            if (!this.target || !this.object) return;
    
            const thisPos = getWorldPosition(this.object).clone();
            const targetPos = getWorldPosition(this.target).clone();
    
            const thisRot = getWorldQuaternion(this.object).clone();
            const targetRot = getWorldQuaternion(this.target).clone();
    
            const thisScale = getWorldScale(this.object).clone();
            const targetScale = getWorldScale(this.target).clone();
    
            const dist = thisPos.distanceTo(targetPos);
            const rotDist = thisRot.angleTo(targetRot);
            const scaleDist = thisScale.distanceTo(targetScale);
    
            if (dist < 0.01 && rotDist < 0.01 && scaleDist < 0.01) {
                setWorldPosition(this.object, targetPos);
                setWorldQuaternion(this.object, targetRot);
                setWorldScale(this.object, targetScale);
                this.coroutine = null;
                return;
            }
    
            let t01 = 0;
            let eased = 0;
            while (t01 < 1) {
    
                t01 += this.context.time.deltaTime / this.duration;
                if (t01 > 1) t01 = 1;
    
                // apply ease-in-out
                // https://easings.net/
                eased = t01 < 0.5 ? 4 * t01 * t01 * t01 : 1 - Math.pow(-2 * t01 + 2, 3) / 2;
    
                this.targetPos.lerpVectors(thisPos, targetPos, eased);
                this.targetRot.slerpQuaternions(thisRot, targetRot, eased);
                this.targetScale.lerpVectors(thisScale, targetScale, eased);
    
                setWorldPosition(this.object, this.targetPos);
                setWorldQuaternion(this.object, this.targetRot);
                setWorldScale(this.object, this.targetScale);
    
                yield;
            }
    
            this.coroutine = null;
        }
    
        private *moveRelative() {
    
            if (!this.target || !this.object) return;
    
            const thisPos = this.object.position.clone();
            const thisRot = this.object.quaternion.clone();
            const thisScale = this.object.scale.clone();
    
            const posOffset = this.target.position.clone();
            const rotOffset = this.target.quaternion.clone();
            const scaleOffset = this.target.scale.clone();
    
            // convert into right space
            posOffset.applyQuaternion(this.object.quaternion);
    
            this.targetPos.copy(this.object.position).add(posOffset);
            this.targetRot.copy(this.object.quaternion).multiply(rotOffset);
            this.targetScale.copy(this.object.scale).multiply(scaleOffset);
    
            let t01 = 0;
            let eased = 0;
            while (t01 < 1) {
    
                t01 += this.context.time.deltaTime / this.duration;
                if (t01 > 1) t01 = 1;
    
                // apply ease-in-out
                // https://easings.net/
                eased = t01 < 0.5 ? 4 * t01 * t01 * t01 : 1 - Math.pow(-2 * t01 + 2, 3) / 2;
    
                this.object.position.lerpVectors(thisPos, this.targetPos, eased);
                this.object.quaternion.slerpQuaternions(thisRot, this.targetRot, eased);
                this.object.scale.lerpVectors(thisScale, this.targetScale, eased);
    
                yield;
            }
    
            this.coroutine = null;
        }
    
        beforeCreateDocument(ext) {
            if (this.target && this.object && this.gameObject) {
                const moveForward = new BehaviorModel("Move to " + this.target?.name,
                    TriggerBuilder.tapTrigger(this.gameObject),
                    ActionBuilder.transformAction(this.object, this.target, this.duration, this.relativeMotion ? Space.Relative : Space.Absolute),
                );
                ext.addBehavior(moveForward);
            }
        }
    }

```

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [January 29, 2025, 10:30am UTC](https://forum.needle.tools/t/missing-dependencies/2216/7 "2025-01-29T10:30:34Z")

</div>

This import is not valid:

`import { Space } from "@needle-tools/engine/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder";`

Importing from a directory that isnt exported. Can you try changing it to `... from "@needle-tools/engine"` ?

If the type is not exported you could as a quick workaround add this to your script at the top and remove the import:

`type Space = "relative" | "absolute";`

---

<div class="post-metadata">

**Author:** ![M\_K](https://forum.needle.tools/user_avatar/forum.needle.tools/m_k/32/3643_2.png) [@M\_K](https://forum.needle.tools/u/M_K)\
**Post date:** [January 29, 2025, 10:56am UTC](https://forum.needle.tools/t/missing-dependencies/2216/8 "2025-01-29T10:56:49Z")

</div>

> [@Marcel\_Wiessler1](#):
>
> If the type is not exported you could as a quick workaround add this to your script at the top and remove the import:
> 
> `type Space = "relative" | "absolute";`

Thanks. I removed the script because I’m not using it in this demo. Now everything functions as it should.

---

<div class="post-metadata">

**Author:** ![system](https://forum.needle.tools/user_avatar/forum.needle.tools/system/32/20_2.png) [@system](https://forum.needle.tools/u/system)\
**Post date:** [February 11, 2025, 10:57am UTC](https://forum.needle.tools/t/missing-dependencies/2216/9 "2025-02-11T10:57:47Z")

</div>

Closed on February 11, 2025, 10:57am UTC

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.
