Importing a script from embedded npmdef in the index.html creates error

I have a project with local npmdefs imported from folders outside the unity project, using those and importing them works fine but I have an embedded npmdef I am importing the same way e.g.

 import { OrbitControlsEpm } from "epm.modelviewer/src/OrbitControlsEpm.ts";
    import { AnimateUV } from "tmsdef/src/AnimateUV.ts";

the epm.modelviewer one imports fine from the Local npmdef in the project but the embedded npmdef called tmsdef gives this error when trying to import any script from it:

192.168.50.90/:45 
        
        
       GET https://192.168.50.90:3000/index.html?html-proxy&index=1.js net::ERR_ABORTED 500 (Internal Server Error)

Why is this happening?

Hi Robyer1! I’m an AI-powered assistant here to help you with questions regarding Needle Engine, three.js, and basic Unity or Blender help. Please provide your OS, Needle Engine version, and Unity or Blender version (if applicable) to assist you further.

2 replies left - GPT 4O
thread_kSH5s7PxzioT7UWnYcOOfP4h
Reply to this message to continue the conversation

Can you clarify what you mean by “embedded npmdef” ? It’s not clear to me what your code examples show

On the npmdef in Unity project explorer in the inspector on location it says ‘embedded’ and that is because the npmdef points to a folder in the Unity Assets directory itself and not outside the Unity project as the npmdef for a folder outside the project says Local instead.

I can probably make a minimal repro of this tomorrow if needed

To me it’s not clear from your error message how it’s related to the import.

Can you show more context of where/how your import scripts?

Internally there’s also no difference for npm between any of these npmdef files - the npmdef effectively just installs your package into your web project and acts as an interface between the Unity UI and what you would otherwise do from a commandline or code editor. You can see that in your web project’s package.json for example in the dependencies array where you can find the packages being registered.

I submitted a minimal bug repro for this that I just made in a new project to show the issue, I have no idea why it causes an issue importing an embedded package vs an external local one

Hi, you’re trying to import a script from a path that doesnt exist:

import { AnimateUV } from "tmsdef/src/AnimateUV.ts";

src/AnimateUV.ts does not exist.

image

The correct import would be import { AnimateUV } from "tmsdef/src/scripts/AnimateUV.js";

Ah I see, I must have missed that the script is in a /src/scripts subfolder and not /src there, apologies for the mixup!

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