Firebase-tools: Unexpected token ... in picomatch/lib/picomatch.js

Created on 1 Sep 2019  路  4Comments  路  Source: firebase/firebase-tools

[REQUIRED] Environment info

Mac, running with npm 8, firebase 7.3.0

I'm going to start with a confession that I'm totally new to npm/js world so I might be missing something obvious. Although, from some time I can't run any firebase cli command (even version, which I know I installed at 7.3.0). It always fails with:

Dominiks-MBP:smart-home-nodejs dombar$ firebase --version
/Users/dombar/.nvm/versions/node/v8.1.2/lib/node_modules/firebase-tools/node_modules/picomatch/lib/picomatch.js:54
    let ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
                       ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/dombar/.nvm/versions/node/v8.1.2/lib/node_modules/firebase-tools/node_modules/picomatch/index.js:3:18)

I tried updating npm/firebase but to no success. Am I missing some update? How can I troubleshoot it? Thanks in advance!

Attention

Most helpful comment

@jmmarco your solution helped, but downgrading this much is probably never a great idea ;)
@bkendall your solution worked as well. Thank you, I ran nvm install 8.16.1 and it fixed the issue.

All 4 comments

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@dbarwacz I think this is happening because you're using Node (version 8) in your system, and apparently Node 8 doesn't support spread syntax on object literals.

I had the same issue. To get it to work I downgraded to firebase-tools version 4.2.1

You can do this by running: npm install -g [email protected]

Update your version of node to the latest 8 branch (since you're using nvm, do nvm install 8.16.1 - and maybe need to do nvm use 8.16.1 - check out nvm's docs for more). The spread in object literals works in later versions of Node 8, but I see you're on 8.1.2 which doesn't support it.

Here's my quick proof on my machine:

禄 node
> process.version
'v8.16.0'
> var o = { foo: 'bar' }
undefined
> { ...o, zip: 'zap' }
{ foo: 'bar', zip: 'zap' }

@jmmarco your solution helped, but downgrading this much is probably never a great idea ;)
@bkendall your solution worked as well. Thank you, I ran nvm install 8.16.1 and it fixed the issue.

Was this page helpful?
0 / 5 - 0 ratings