Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gulp: ERR_UNKNOWN_FILE_EXTENSION #2126

Open
binarykitchen opened this issue Jul 12, 2024 · 3 comments
Open

Gulp: ERR_UNKNOWN_FILE_EXTENSION #2126

binarykitchen opened this issue Jul 12, 2024 · 3 comments

Comments

@binarykitchen
Copy link

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

  • ts-node version: v10.9.2
  • node version: v20.12.2
  • TypeScript version: 5.5.3
  • tsconfig.json, if you're using one:
{
  "include": [
    "etc",
    "src",
    "test",
    "gulpfile.ts",
    ".eslintrc.js",
    "prettier.config.js",
    "babel.config.js"
  ],
  "compilerOptions": {
    // Required
    "target": "esnext",
    "module": "CommonJS",

    "noEmit": true,
    "allowImportingTsExtensions": true,
    "allowArbitraryExtensions": true,
    "isolatedModules": true,
    "esModuleInterop": true,

    "lib": ["dom", "dom.iterable", "esnext"],

    "skipLibCheck": true,
    "strict": true,
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "allowUnusedLabels": false,
    "allowUnreachableCode": false,
    "exactOptionalPropertyTypes": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noEmitOnError": true,
    "stripInternal": true,

    "resolveJsonModule": true,

    // TODO remove these exceptions and fix more errors one day
    "noImplicitAny": false
  }
}

  • 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
Copy link

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

@binarykitchen
Copy link
Author

Figured out an ugly workaround for now:

node --require tsx/cjs node_modules/gulp-cli/bin/gulp.js

@kooriookami
Copy link

This works, but still ugly.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants