firebase 函数错误:在本地服务时无法找到模块,在以前的工作项目中突然出现

Mic*_*elB 5 firebase typescript google-cloud-functions

我还没有接触过任何与 firebase 相关的文件,而且我似乎无法弄清楚为什么这种情况刚刚开始发生,但我不断收到:

We were unable to load your functions code. (see above)
   - It appears your code is written in Typescript, which must be compiled before emulation.
   - You may be able to run "npm run build" in your functions directory to resolve this.
Run Code Online (Sandbox Code Playgroud)

我的 firebase 配置文件:

{
    "functions": {
        "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build",
        "source": "server"
    }
}

Run Code Online (Sandbox Code Playgroud)

和我的文件夹结构:

在此输入图像描述

我的 tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es6",
    "sourceMap": true,
    "outDir": "./dist"
  },
  "exclude": ["node_modules", "test", "**/*spec.ts"],
  "include": ["src/**/*", "src"]
}

Run Code Online (Sandbox Code Playgroud)

Jim*_*ane 2

就我而言,我不小心从函数的父项目中导入了未编译的 Typescript 文件。

通常,这是一个应该是包依赖项的库。