remix icon indicating copy to clipboard operation
remix copied to clipboard

TypeError: Unknown file extension ".ts". Not working dev/build with express server and import files

Open EvgeniyBudaev opened this issue 1 year ago • 1 comments

Reproduction

https://github.com/EvgeniyBudaev/remixjs-2-8 I have server.ts. There are a lot of imported files in the server.ts. I'm executing the command npm run dev and get an error "TypeError: Unknown file extension ".ts""

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz
    Memory: 45.97 GB / 62.57 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.11.1/bin/npm
  Browsers:
    Chrome: 122.0.6261.128
  npmPackages:
    @remix-run/css-bundle: ^2.8.1 => 2.8.1 
    @remix-run/dev: ^2.8.1 => 2.8.1 
    @remix-run/node: ^2.8.1 => 2.8.1 
    @remix-run/react: ^2.8.1 => 2.8.1 
    @remix-run/serve: ^2.8.1 => 2.8.1

Used Package Manager

npm

Expected Behavior

The project is launched

Actual Behavior

TypeError: Unknown file extension ".ts" for /home/ebudaev/Documents/Others/MyProjects/NewRemix/remixjs-2-8/server.ts at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9) at defaultGetFormat (node:internal/modules/esm/get_format:203:36) at defaultLoad (node:internal/modules/esm/load:143:22) at async ModuleLoader.load (node:internal/modules/esm/loader:409:7) at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45) at async link (node:internal/modules/esm/module_job:76:21) { code: 'ERR_UNKNOWN_FILE_EXTENSION' } 2024-03-21_09-27-01

EvgeniyBudaev avatar Mar 21 '24 06:03 EvgeniyBudaev

@EvgeniyBudaev I recommend you switch to tsx instead of ts-node.

There is an issue with ts-node and Node 20+ (see here).

alcpereira avatar Mar 26 '24 23:03 alcpereira