0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Typescriptを動かす([ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" を解決)

Last updated at Posted at 2025-04-14

今回の問題

ts-nodeを使用して以下のエラーが起きた。
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

これが原因で実行できない。

解決策

以下のコマンドでプロジェクトを作成する。

$ mkdir project 
$ npm install --save-dev typescript
$ npx tsc --init
$ npm i -D tsx

以下のコマンドで実行する

$ npx tsx index.ts

結果

色々なサイトで確認しましたが、ts-nodeなどを使用しても実現できませんでした。
結果的にこちらの手順に行き着きました。
原因の確認はできませんでしたので、今後確認したいと思います。
(知見のある方コメントお願いします。)
ご参考になればと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?