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

Firebase Cloud Functions部署报错TS18003:tsconfig.json无输入文件

解决Firebase Cloud Functions部署时TS18003错误

问题场景

原有Firebase Cloud Functions(Node.js)运行正常,新增函数后部署报错,错误提示TS18003,找不到tsconfig指定的输入文件。

新增函数代码

exports.getNewTest=functions.https.onRequest((request, response) => {
    response.end("Hello World");
});

CLI部署日志

Build failed: > build
> tsc

error TS18003: No inputs were found in config file '/workspace/tsconfig.json'. Specified 'include' paths were '["src"]' and 'exclude' paths were '["lib"]'.; Error ID: 1a2262f3

Functions deploy had errors with the following functions:
        getNewTest
i  functions: cleaning up build files...

Error: There was an error deploying functions

Having trouble? Try again or contact support with contents of firebase-debug.log

当前tsconfig.json配置

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": false,
    "outDir": "lib",
    "sourceMap": true,
    "strict": false,
    "target": "es2020",
    "allowJs": true
  },
  "compileOnSave": false,
  "include": [
    "src"
  ]
}

已尝试添加"exclude": ["lib"],问题未解决。

解决方案

1. 检查文件目录结构

TypeScript找不到输入文件的核心原因是你的函数代码文件不在tsconfig指定的src目录下。

  • 确保所有函数代码(包括新增的getNewTest)都放在项目根目录的src文件夹内,标准目录结构示例:
    项目根目录
    ├── src/
    │   └── index.ts  // 所有函数写在这里,或拆分到src下的其他ts文件
    ├── tsconfig.json
    └── package.json
    

2. 调整tsconfig的include配置(可选,优先规范目录)

如果函数文件确实需要放在src外(比如根目录的index.ts),修改tsconfig.json的include数组,把对应文件/目录加入:

"include": [
  "src",
  "index.ts"  // 新增该行,包含根目录的index.ts
]

3. 本地预编译验证

在项目根目录执行tsc命令,确认本地编译无TS18003错误后,再重新部署:

firebase deploy --only functions

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 23:40:29