TypeScript「Option 'baseUrl' is deprecated」の原因と直し方
Option 'baseUrl' is deprecated は、6.0 で非推奨になった指定が tsconfig にあると出る。
今は "ignoreDeprecations": "6.0" で通るが、7.0 に備えて baseUrl を消し、paths を ./ 始まりに直す。
公開:
npx tsc -p . tsconfig.json(5,25): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. Visit https://aka.ms/ts6 for migration information. tsconfig.json(6,5): error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. Visit https://aka.ms/ts6 for migration information.
npx tsc -p .
2026-11-07 に node:24(TypeScript 6.0.3 / Node.js 24.22.2) で実際に打って取った出力。検証環境の詳細
要約
error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. は、TypeScript 6.0 で非推奨になった指定が tsconfig.json にあると出るエラーだ。"moduleResolution": "node" のように値が非推奨になったものは、TS5107: Option 'moduleResolution=node10' is deprecated ... と指定と値の組で出る。
どちらも警告ではなく、tsc は終了コード 2 で止まる。
いますぐ通すなら、tsconfig.json に "ignoreDeprecations": "6.0" を足す。
この指定は 7.0 では効かないので、7.0 に上げる前に baseUrl を消し、paths を ./ 始まりに書き直す。
実行例
node:24 のコンテナで、baseUrl と "moduleResolution": "node" を書いた tsconfig.json を TypeScript 6.0.3 と 5.9.3 の tsc にかけた。
6.0.3 は ignoreDeprecations を足すと通り、baseUrl を消して paths を ./ 始まりにすると ignoreDeprecations なしでも終了コードが 0 になった。
$ npx tsc -v
Version 6.0.3$ cat tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"module": "commonjs",
"moduleResolution": "node",
"baseUrl": ".",
"paths": { "@/*": ["src/*"] }
},
"include": ["src"]
}$ npx tsc -p .
tsconfig.json(5,25): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
Visit https://aka.ms/ts6 for migration information.
tsconfig.json(6,5): error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
Visit https://aka.ms/ts6 for migration information.
$ echo $?
2$ cat tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"module": "commonjs",
"moduleResolution": "node",
"baseUrl": ".",
"paths": { "@/*": ["src/*"] },
"ignoreDeprecations": "6.0"
},
"include": ["src"]
}$ npx tsc -p .
$ echo $?
0$ npx tsc -v
Version 5.9.3$ npx tsc -p .
tsconfig.json(8,27): error TS5103: Invalid value for '--ignoreDeprecations'.
$ echo $?
2$ cat tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"module": "commonjs",
"moduleResolution": "bundler",
"paths": { "@/*": ["src/*"] }
},
"include": ["src"]
}$ npx tsc -p .
tsconfig.json(6,24): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
$ echo $?
2$ cat tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"module": "commonjs",
"moduleResolution": "bundler",
"paths": { "@/*": ["./src/*"] }
},
"include": ["src"]
}$ npx tsc -p .
$ echo $?
0— 2026-11-07 時点の出力
検証環境Node.js 24.22.2 / npm 11.19.1 / Python 3.11.2 / 2026-11-07 検証(ほか 2 件)
- 検証日
- 実行環境
node:24Debian GNU/Linux 12 (bookworm)- バージョン
- Node.js 24.22.2
- npm 11.19.1
- Python 3.11.2
- Git 2.39.5
- TypeScript 6.0.3
この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。
解決策
1. いま通すなら ignoreDeprecations を足す
{
"compilerOptions": {
"baseUrl": ".",
"paths": { "@/*": ["src/*"] },
"ignoreDeprecations": "6.0"
}
}エラーの文言のとおり、値は "6.0" と書く。
5.x の tsc はこの値を知らないので、同じ tsconfig.json を読むと TS5103: Invalid value for '--ignoreDeprecations'. で止まる。
モノレポや CI で 5.x と 6.0 が同じ tsconfig.json を読むなら、全部を 6.0 に上げてから足す。
2. baseUrl を消して paths を ./ 始まりにする
{
"compilerOptions": {
"paths": { "@/*": ["./src/*"] }
}
}baseUrl だけを消すと、./ の無い "src/*" が TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. になる。baseUrl が無いとき、paths の行き先は tsconfig.json からの相対パスで書く。baseUrl が "." 以外だったなら、その値を行き先の前に足す。
"baseUrl": "src" で lib/math のように読んでいたなら、"paths": { "*": ["./src/*"] } と書けば同じパスで解決される。paths は型の検査にしか効かないので、実行時の解決はバンドラー側の設定のまま残す(paths の記事)。
3. moduleResolution: node を替える
Vite や webpack でまとめるプロジェクトは "moduleResolution": "bundler" にする。
6.0 では "module": "commonjs" と組み合わせても通るので、module は変えなくてよい。
Node.js で直接動かすプロジェクトは "module": "nodenext" にすると、moduleResolution も nodenext になる(NodeNext の拡張子の記事)。
4. ignoreDeprecations を消して確かめる
書き直したら ignoreDeprecations の行を消し、npx tsc -p . を打つ。
ここで TS5101 / TS5107 が出なければ、7.0 に上げても tsconfig.json の指定では止まらない。
7.0 では同じ指定が TS5102 / TS5108 になり、ignoreDeprecations でも黙らない(7.0 の記事)。
よくある原因
- 5.x の頃に作った tsconfig.json に
"baseUrl": "."や"moduleResolution": "node"が残っている。
5.x では何も出なかった指定が、6.0 に上げた時点でエラーになる。 baseUrlをimportの起点にしている。"baseUrl": "src"と書いてimport { add } from "lib/math"のように読む使い方で、pathsを書いていなくても同じTS5101になる。- 6.0 で非推奨になったほかの指定が残っている。
"target": "es5"と"esModuleInterop": falseはTS5107、"downlevelIteration": trueはTS5101で止まる。