firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Error on firebase deploy for version 3.17.6

Open MehranJanfeshan opened this issue 8 years ago • 15 comments

Version info

3.17.6

Platform Information

LINUX

Steps to reproduce

Run $ firebase use --token $FIREBASE_DEPLOY_KEY

Error:

/usr/local/lib/node_modules/firebase-tools/node_modules/sntp/lib/index.js:19
exports.time = async function (options = {}) {
                     ^^^^^^^^
SyntaxError: Unexpected token function
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/hawk/lib/index.js:5:16)
    at Module._compile (module.js:570:32)

Expected behavior

Deploy project to firebase host

MehranJanfeshan avatar Mar 12 '18 09:03 MehranJanfeshan

Me too 💃

quanganh206 avatar Mar 12 '18 10:03 quanganh206

Same issue, hawk module only is compatible with node 8.9

diego-pascual avatar Mar 12 '18 10:03 diego-pascual

I'm also experiencing the same exact error whenever I attempt to deploy, I checked here to see if it was already an issue. Currently unable to deploy any of my functions.

Update: Downgrading to firebase-tools version 3.17.5 with node version 6.13.1 resolved the issue for me.

donth77 avatar Mar 12 '18 10:03 donth77

Same here.

The error happens when I just enter 'firebase' in the console.

jaakidup avatar Mar 12 '18 10:03 jaakidup

I have upgraded to the latest version of node and it works perfectly, I still cannot figure out how the older versions of firebase-tools that were working fine they stopped working. I have event downgraded to 3.0.0 and still, I got the error. they only solution for me was upgrading to the latest version of Node.

MehranJanfeshan avatar Mar 12 '18 10:03 MehranJanfeshan

@MehranJanfeshan async/await isn't supported on node 6 (which is run on GCP functions). I might suggest you apply babel transformation before uploading your code.

Rulsky avatar Mar 12 '18 10:03 Rulsky

@Rulsky, That's the weird part, the deployment was working fine, even with node 6.9.0 but suddenly it thrown an error, Upgrade to latest node fixed the problem.

MehranJanfeshan avatar Mar 12 '18 10:03 MehranJanfeshan

@MehranJanfeshan try to deploy a really simple function which will output version of the node on you cloud functions

const version = https.onRequest('/version', (req, res) => {
  res.send(process.version)
})
module.exports = {
  version
}

This way you will know for sure on what version of node you are running.

BTW, you can borrow some ideas of transforming modern es syntax into node 6 compatible from my helper util - https://github.com/Rulsky/cra-firebase

Rulsky avatar Mar 12 '18 10:03 Rulsky

@MehranJanfeshan How are you installing firebase-tools? What command did you run?

As well, can you run npm ls sntp inside the directory where firebase-tools is installed (find this by running which firebase) and copy and paste the output? The error message comes form sntp, but pre-v3 it did not use async functions. So I'm curious which version got installed for you.

laurenzlong avatar Mar 12 '18 18:03 laurenzlong

@Rulsky It seems like the "async" function is actually in a dependency of firebase-tools, not in the user's functions code. Your suggestion is good for debugging errors within the functions code, but doesn't apply in this case.

laurenzlong avatar Mar 12 '18 18:03 laurenzlong

@laurenzlong guess because node 8 is in LTS for a really long time and people use it as default environment on their machines. Any information on when cloud functions will switch to node 8?

Rulsky avatar Mar 12 '18 19:03 Rulsky

@laurenzlong I have installed firebase-tools with this command: npm install -g firebase-tools and node version was 6.9.0, I had this set in the pipeline for few months and it was working fine till yesterday that throws an error.

MehranJanfeshan avatar Mar 13 '18 02:03 MehranJanfeshan

Can you run npm ls sntp inside the directory where firebase-tools is installed (find this by running which firebase) and copy and paste the output?

laurenzlong avatar Mar 13 '18 19:03 laurenzlong

And can you also tell me your npm version? Run npm --version.

laurenzlong avatar Mar 13 '18 19:03 laurenzlong

Closing as this is using an outdated version of firebase-tools. If you're still seeing this for version ^6.0.0 please open another issue.

tinaliang avatar Jan 09 '19 01:01 tinaliang