You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 11下Node.js执行npm run build遇TS18003错误如何修复?

解决TypeScript编译错误TS18003: No inputs were found in config file

问题场景

Windows 11系统下,在CMD执行npm run build时触发错误:error TS18003: No inputs were found in config file,相关配置如下:

package.json

package.json截图

tsconfig.json

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "rootDir": "XSHOPPER-BACKEND",
    "moduleResolution": "node",
    "outDir": "build",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

错误截图

修复步骤

这个错误核心是TypeScript无法找到需要编译的.ts文件,按以下步骤排查修复:

  • 校验目录结构:确认XSHOPPER-BACKEND目录存在于tsconfig.json所在的同级路径下,且该目录内确实包含TypeScript源码文件(.ts后缀)。如果目录名称或路径有误,直接修正目录名或者调整tsconfig里的rootDir值。

  • 添加include配置:在tsconfig.json中补充include字段,明确指定需要编译的文件范围,确保TypeScript能定位到源码:

    {
      "compilerOptions": {
        "target": "es2016",
        "module": "commonjs",
        "rootDir": "XSHOPPER-BACKEND",
        "moduleResolution": "node",
        "outDir": "build",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "skipLibCheck": true
      },
      "include": ["XSHOPPER-BACKEND/**/*"]
    }
    

    这里的**/*表示匹配XSHOPPER-BACKEND目录下所有子目录和文件。

  • 检查npm脚本:确认package.json中的build脚本是正确调用tsc命令,比如如果脚本是"build": "tsc",要保证tsconfig.json在项目根目录;如果配置文件在其他路径,需指定路径:"build": "tsc --project ./config/tsconfig.json"。

  • 修正大小写问题:Windows系统不区分路径大小写,但TypeScript的forceConsistentCasingInFileNames配置为true时,会强制校验路径大小写一致性,确认XSHOPPER-BACKEND的大小写和实际目录完全匹配。


内容的提问来源于stack exchange,提问作者user17281794

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 16:48:23