# Scripts no longer work, npmdef error message

**URL:** <https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914>\
**Category:** 🌵 Needle Engine\
**Tags:** question\
**Created:** [October 28, 2026, 10:31am UTC](https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914 "2026-10-28T10:31:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [October 28, 2026, 10:31am UTC](https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914/1 "2026-10-28T10:31:29Z")

</div>

I made a few changes to my scene (changed the videoplayer from trying to play a Youtube URL to playing a local mp4 file) and all of a sudden I get errors that my own scripts are unknown components in the scene and that I might be missing an npmdef.

How did this happen? I did not change anything in the npmdefs.

Here’s the error:

 ![Needle NPMDef problem](https://forum.needle.tools/uploads/default/original/2X/3/3d4faba3644ee3eb7d448d4a854f78d395e2780c.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:** [October 28, 2026, 10:31am UTC](https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914/2 "2026-10-28T10:31:29Z")

</div>

The “unknown component / missing npmdef” message means a component in your scene can’t be resolved at runtime — usually its TypeScript wasn’t registered/transpiled when the scene was exported, not that you broke the npmdef.

The most likely cause for what you describe: **stale codegen after re-exporting the scene.** The script‑registration pass runs for scenes that carry a `Needle Engine` component — but for **sub-scenes exported as references** , that codegen does _not_ re-run, so newly serialized components aren’t found:

> “When creating new scripts in npmdefs in sub-scenes… you currently have to re-export the root scene again. This is because the code-gen that is responsible for registering new scripts currently only runs for scenes with a `Needle Engine` component.”  
> [Questions and Answers (FAQ) 💡 | docs](https://engine.needle.tools/docs/reference/faq.html)

So even touching only the scene (changing the video source) can trigger a re-export that desynchronizes the generated component mappings.

**Next steps:**

1. Make sure the scene with the `Needle Engine` component is exported last, and re-export the **root** scene (not just the sub-scene).
2. Fully **restart the dev server** after re-export so codegen picks up the changes (`Codegen`/`Needle` log should show generated components).
3. Confirm your npmdef is still in the `Needle Engine` component’s **dependencies** list on that root scene and installed.

If those don’t fix it, share which scene you changed the video player in (root vs. a sub-scene/reference) — you can connect your project in [Needle Cloud AI](https://cloud.needle.tools/) so the actual logs can be inspected.

For project-specific help, ask [Needle Cloud AI](https://cloud.needle.tools/).

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [October 28, 2026, 10:37am UTC](https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914/3 "2026-10-28T10:37:01Z")

</div>

All right, saving the scene and exporting it a third time solved it. Weird…

---

<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:** [October 28, 2026, 10:37am UTC](https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914/4 "2026-10-28T10:37:02Z")

</div>

Good to hear it’s working — and that’s actually a known quirk, not magic. Script registration/codegen only runs when exporting a scene with a `Needle Engine` component; **sub-scenes exported as references don’t re-run that codegen** , so a re-export can leave the generated component registry out of sync with what’s serialized in the scene. A second/third export picks up the new state.

The related FAQ note:

> “When creating new scripts in npmdefs in sub-scenes… you currently have to re-export the root scene again.”  
> [Questions and Answers (FAQ) 💡 | docs](https://engine.needle.tools/docs/reference/faq.html)

**Tip for next time:** if you hit it again, delete the generated `scripts/` folder (and the `Needle` npmdef artifacts) before re-exporting, so the mapping is rebuilt from scratch instead of merged with stale entries. That makes the fix deterministic instead of “export until it works.”

For project-specific help, ask [Needle Cloud AI](https://cloud.needle.tools/).

---

<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:** [November 10, 2026, 10:37am UTC](https://forum.needle.tools/t/scripts-no-longer-work-npmdef-error-message/2914/5 "2026-11-10T10:37:18Z")

</div>

Closed on November 10, 2026, 10:37am UTC

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