UCL-VR / ubiq

Other
98 stars 34 forks source link

Ubiq Node server not starting #47

Closed TheBv closed 7 months ago

TheBv commented 7 months ago

Simply put running npm i followed by npm run start won't actually start the server. Instead I get the following error:

H:\Repos\Uni\ubiq-dev\Node\node_modules\ts-node\dist-raw\node-internal-modules-esm-get_format.js:93
        throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url));
              ^
CustomError: ERR_UNKNOWN_FILE_EXTENSION .ts H:\Repos\Uni\ubiq-dev\Node\node_modules\ubiq\index.ts

Hint:
ts-node is configured to ignore this file.
If you want ts-node to handle this file, consider enabling the "skipIgnore" option or adjusting your "ignore" patterns.

Main issue being that we are installing the submodules as dependencies but these are never transpiled to javascript. So we'd need to tell ts-node that it's allowed to also transpile typescript files by adding the skipIgnore flag. E.g ts-node-esm --skipIgnore app.ts

I'm not fully convinced that that's the best solution especially since this also requires us to add to @types dependencies since they are required by the ubiq-module.

Maybe I'm missing something though. Otherwise I'd suggest that it might be a good idea to add a build step to the project that builds the various modules.

sebjf commented 7 months ago

Hi @TheBv,

Could you say more about the environment you are running in/what the setup is?

If inside a new folder, I do a git clone and start the server, like so, it works OK:

$ git clone git@github.com:UCL-VR/ubiq.git .
$ cd Node/
$ npm i
$ npm start

Main issue being that we are installing the submodules as dependencies but these are never transpiled to javascript.

Do you mean to say that for your particular project you are including the ubiq server components as submodules in your project? And when transpiling your project it fails to transpile those?

Otherwise I'd suggest that it might be a good idea to add a build step to the project that builds the various modules.

This is a good suggestion for those that might want to transpile rather than use a loader. I will see if I can add a command to the package which demonstrates this.

TheBv commented 7 months ago

Could you say more about the environment you are running in/what the setup is?

Good point. I've just tried this with node version 18 and it works fine. I was using 19 before so I assume this might be an issue with versions >=19

Sorry for not considering that earlier ^^"

I think the easiest fix would probably to add an "engines" entry to the package.json.

sebjf commented 7 months ago

Hi @TheBv, thank you for the update!

I did a quick test of versions 20.11.0 and 19.4.0 and was able to start with those. Do you have the exact version of 19 you were using so I can try it?

TheBv commented 7 months ago

Node 19.4.0 with npm 9.2.0. Also make sure you rerun npm install since changing versions seems to install different packages. Happens both on Windows and Ubuntu.

sebjf commented 7 months ago

OK I see the same thing now with 19.4.0 & npm 9.2.0.

It seems version 19.7.0 and above work again.

I will add the engines section to the package to prohibit this set of versions, as suggested!

sebjf commented 7 months ago

Done. Thanks for the reporting the issue!