首页 > 解决方案 > 从 Cloud Function 中的 firebase 存储下载时出错

问题描述

我有以下代码可以从 Firebase 存储中下载 .txt 文件:

    const objectName = `${isla}/${localidad}/${zona}/map.txt`;
    const file = storage.bucket(config["storageBucket"]).file(objectName);
    const tmpFilePath = path.join(os.tmpdir(), "map.txt");
    await file.download({destination: tmpFilePath});

但它会引发错误:

    Error: _read() is not implemented at Duplex.Readable._read 
    (_stream_readable.js:551:22) at Duplex.Readable.read 
    (_stream_readable.js:442:10) at resume_ (_stream_readable.js:822:12) at 
    _combinedTickCallback (internal/process/next_tick.js:139:11) at 
    process._tickDomainCallback (internal/process/next_tick.js:219:9)

我以前使用过这种方法没有问题,不确定我做错了什么,因为我没有尝试设置流。任何帮助表示赞赏,谢谢。

标签: javascriptnode.jsgoogle-cloud-functionsgoogle-cloud-storage

解决方案


正如@bob2 提到的,这是一个已知的错误

该错误中建议的解决方法是:

如果您 rm -rf node_modules package-lock.json 然后再次 npm install ,一切都应该按预期工作。


推荐阅读