TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.84k stars 534 forks source link

Gulp: ERR_UNKNOWN_FILE_EXTENSION #2126

Open binarykitchen opened 1 month ago

binarykitchen commented 1 month ago

Unable to run gulp command when gulpfile.ts is in TypeScript

Expected Behaviour

npx gulp

Should build. Pass.

Actual Behaviour

/home/michael-heuberger/code/binarykitchen/videomail.io ❯❯❯ npx gulp                                                                                feature/typescript ✭ ✱
[15:57:06] Loaded external module: ts-node/register
TypeError: Unknown file extension ".ts" for /home/michael-heuberger/code/binarykitchen/videomail.io/gulpfile.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:403:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45)
    at async link (node:internal/modules/esm/module_job:78:21) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Gulp's official documentation says it should work, see: https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/

Likewise, your documentation says the same: https://github.com/TypeStrong/ts-node/blob/main/website/docs/recipes/gulp.md?plain=1

Specifications



* Operating system and version: Arch Linux

I've tried many different configurations and combinations. All my attempts failed. No idea why it says `.ts` is an unknown extension?
kooriookami commented 1 month ago

I have this problem too. My node version is v18.19.1.

binarykitchen commented 1 month ago

Figured out an ugly workaround for now:

node --require tsx/cjs node_modules/gulp-cli/bin/gulp.js
kooriookami commented 1 month ago

This works, but still ugly.

tsx node_modules/gulp-cli/bin/gulp.js