typescript - firebase 函数错误 : Cannot find module when serving locally, 在以前工作的项目中突然出现

标签 typescript firebase 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.

我的 Firebase 配置文件:
{
    "functions": {
        "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build",
        "source": "server"
    }
}


和我的文件夹结构:

enter image description here

我的 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"]
}

最佳答案

就我而言,我不小心从函数的父项目中导入了一个未编译的 Typescript 文件。
通常这是一个应该是包依赖项的库。

关于typescript - firebase 函数错误 : Cannot find module when serving locally, 在以前工作的项目中突然出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58627089/

相关文章:

json - 我如何在不知道 name 属性的对象数组中执行 *ngFor ?

javascript - Typescript "Element implicitly has an ' any' 类型,因为类型 'Rank' 的表达式不能用于索引类型 'IPowerCards' "

swift - 我如何在注册用户时提供安全性? (例如 : each username must be different, 电子邮件必须有效等)

node.js - 将新集合添加到 firestore 中现有文档的云功能

google-cloud-datastore - 如何在 Google Cloud Functions 中获取当前的 projectId?

typescript - 键入第二深度界面对象的键

angular - Ionic 3 - 运行时错误无法读取 null 的属性 'scrollToTop'

database - 在 Firestore 中查询没有映射键的文档

java - 如何根据条件从firebase数据库中获取图像url并将其加载到ImageView中?

firebase - 是否可以在 firebase 上运行 graphql 订阅?