1

皇冠hg0088代理网址I am trying to deploy a firebase function with the command firebase deploy, but when I import @google-cloud/storage

const { Storage } = require('@google-cloud/storage');

I get this error

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)

The problem is that I found this error in p-limit/index.js in the following code

    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();
};

皇冠hg0088代理网址But if I edit this part of the code and deploy again, I get the same error, so it seems that it's not reading this file.. it's getting this error in some other place that I cant find..

皇冠hg0088代理网址Someone can help?

  • 1
    Having the same issue here. What is weird is the commit that changed that line in p-limit is around 16 days ago but we only started having the problem 2 days ago. I left a comment for the developer about it hoping he will fix it: – Tarek Jun 22 at 18:29
5

What version of node are you running? I had the same exact same message when I tried using it today and has been driving me crazy. I was using Node 8.12. Try upgrading to the latest version of node 12.18.1. It resolved that error for me.

| improve this answer | |
  • You are right! I changed the node version to 10 (the last) inside package.json in the function folder, so it deployed in node 10 inside the cloud, instead version 8... so it worked Thanks! – gara Jun 22 at 13:21
0

It worked following these steps

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy皇冠hg0088代理网址

Not the answer you're looking for? Browse other questions tagged or ask your own question.