导入 @google-cloud/storage 以部署 firebase 函数时 p-limit lib 出错

pol*_*nio 1 function node.js firebase

我正在尝试使用命令 firebase deploy 部署 firebase 函数,但是当我导入 @google-cloud/storage 时

const { Storage } = require('@google-cloud/storage');
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

Detailed stack trace: /srv/node_modules/p-limit/index.js:30
            } catch {}
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/node_modules/@google-cloud/storage/build/src/bucket.js:25:16)
Run Code Online (Sandbox Code Playgroud)

问题是我在下面的代码中在p-limit/index.js中发现了这个错误

    const run = async (fn, resolve, ...args) => {
    activeCount++;

    // TODO: Get rid of `pTry`. It's not needed anymore.
    const result = pTry(fn, ...args);

    resolve(result);

    try {
        await result;
    } catch {}

    next();
};
Run Code Online (Sandbox Code Playgroud)

但是如果我编辑这部分代码并再次部署,我会得到同样的错误,所以它似乎没有读取这个文件..它在我找不到的其他地方得到这个错误..

有人可以帮忙吗?

小智 6

您正在运行什么版本的节点?当我今天尝试使用它时,我收到了完全相同的消息,并且一直让我发疯。我使用的是 Node 8.12。尝试升级到最新版本的节点 12.18.1。它为我解决了这个错误。