1

when I run the gulp build command in the project, shows error:

> gulp build
[19:18:42] Requiring external module ts-node/register
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/xiaoqiangjiang/source/reddwarf/frontend/codemirror-tex/packages/lang-tex/gulpfile.ts
    at new NodeError (node:internal/errors:371:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:87:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:102:38)
    at defaultLoad (node:internal/modules/esm/load:21:14)
    at ESMLoader.load (node:internal/modules/esm/loader:359:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:58)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:297:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:261:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

this is the project tsconfig.json look like:

{
  "extends": "./tsconfig.build.json",
  "compilerOptions": {
    "module": "commonjs",
    "rootDir": "."
  },
  "include": ["src", "tests", "tools", "playground", "scripts", "**/*.json"]
}

I have tried to tweak the tsconfig like this follow the Can't run my Node.js Typescript project TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/App.ts, still could not fixed this issue:

{
  "extends": "./tsconfig.build.json",
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Node",
    "rootDir": "."
  },
  "include": ["src", "tests", "tools", "playground", "scripts", "**/*.json"]
}

what should I do to fixed this issue? this is the project package.json:

{
  "name": "rd-lang-tex",
  "version": "0.0.2",
  "description": "TeX extension for CodeMirror 6",
  "keywords": [
    "tex",
    "codemirror",
    "codemirror6",
    "latex",
    "cm6",
    "cm",
    "language"
  ],
  "author": "mu.io <[email protected]>",
  "homepage": "https://github.com/mu-io/codemirror-tex",
  "license": "GPL-3.0-or-later",
  "main": "lib/index.js",
  "type": "module",
  "directories": {
    "lib": "lib"
  },
  "files": [
    "lib"
  ],
  "publishConfig": {
    "access": "public"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/mu-io/codemirror-tex.git"
  },
  "scripts": {
    "serve": "gulp serve",
    "build": "gulp build"
  },
  "devDependencies": {
    "@types/gulp": "^4.0.16",
    "@types/gulp-sourcemaps": "^0.0.34",
    "@types/jest": "^26.0.24",
    "@types/webpack-dev-server": "^3.11.6",
    "clean-webpack-plugin": "^3.0.0",
    "codemirror": "^6.0.1",
    "gulp": "^4.0.2",
    "gulp-sourcemaps": "^3.0.0",
    "gulp-typescript": "6.0.0-alpha.1",
    "html-webpack-plugin": "^5.5.3",
    "jest": "^26.6.3",
    "ts-jest": "^26.5.6",
    "ts-loader": "^8.4.0",
    "ts-node": "10.8.1",
    "typescript": "^4.9.5",
    "webpack": "^5.89.0",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^4.15.1"
  },
  "dependencies": {
    "@codemirror/autocomplete": "^0.18.8",
    "@codemirror/closebrackets": "^0.18.0",
    "@codemirror/highlight": "^0.18.4",
    "@codemirror/language": "^0.18.2",
    "@codemirror/state": "^6.3.1",
    "@lezer/lr": "^1.3.13",
    "rd-lezer-tex": "^0.0.1"
  },
  "bugs": {
    "url": "https://github.com/mu-io/codemirror-tex/issues"
  }
}

I have read this issue https://github.com/TypeStrong/ts-node/issues/1997, seems node 20 will facing this issue, but my node version is 16:

> node -v
v16.14.2

I also tried to remove "type": "module" in package.json, still could not fix this issue. This advice is come from https://github.com/TypeStrong/ts-node/issues/1062.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.