我没有触及任何与 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"
}
}
和我的文件夹结构:
我的 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/