3.17.6
LINUX
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)
Deploy project to firebase host
Me too 馃拑
Same issue, hawk module only is compatible with node 8.9
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.
Same here.
The error happens when I just enter 'firebase' in the console.
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 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, 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 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
@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.
@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 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?
@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.
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?
And can you also tell me your npm version? Run npm --version.
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.
Most helpful comment
@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?