[typescript] ERROR TS18002: The 'files' list in config file 'tsconfig.json' is empty.

網上可搜到的解決辦法是修改webpack配置,顯示指定tsconfig.json
個人理解:這樣做意外着webpack沒有找到配置文件,並不是報錯中說的files選項爲空
但修改配置後並沒解決整個報錯
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFile: path.resolve(__dirname, '../tsconfig.json')
 }
}
 
 
 
查看ts-loader官方文檔,上面關於依賴的兼容性提出:
Compatibility:webpack: 4.x+ (please use ts-loader 3.x if you need webpack 2 or 3 support)
工程用的是webpack3,因此開始降級ts-loader
npm uninstall ts-loader // "ts-loader": "^7.0.1",
npm install ts-loader@3 -D // 安裝大版本3下的最新版本 + [email protected]
npm install ts-loader@"<4.0.0" -D // 安裝大版本3下的最新版本 + [email protected]
 
最後發現還有個問題就是tsconfig.json文件名後面多了一個空格
'tsconfig.json ' 去掉空格即可解決 'tsconfig.json'
難怪在vscode中沒有高亮這個json文件=_=!
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章