【发布时间】:2021-01-09 19:57:12
【问题描述】:
我有一个 Firebase 函数,想读取一个 html 文件,存储在一个子文件夹中。
── functions
├── src
| ├── index.ts // Here is the function
| ├── html
| | ├── template.html // the file I want to read
我尝试通过const html = fs.readFileSync('./html/template.html'); 读取文件,但它总是告诉我
错误:ENOENT:没有这样的文件或目录,打开 './html/template.html' 在 Object.openSync
我几乎解决了有关此主题的 stackoverflow 上的所有问题,但对我没有任何帮助。我也尝试将文件放在与函数相同的文件夹中,但它总是给我错误。
我是否需要安装一些包或以某种方式导入文件才能访问它?
【问题讨论】:
标签: typescript firebase file google-cloud-functions