firebase-functions: Engines node 8 not working

My functions/package.json:

"dependencies": {
  "express": "^4.16.3",
  "firebase-admin": "^5.13.1",
  "firebase-functions": "^2.0.2",
  "nuxt": "^1.4.2"
},
"devDependencies": {
  "babel-core": "^6.26.3",
  "babel-eslint": "^8.2.6",
  "babel-loader": "^7.1.5",
  "babel-plugin-transform-runtime": "^6.23.0",
  "babel-preset-es2015": "^6.24.1",
  "babel-preset-stage-2": "^6.24.1"
},
"engines": {
  "node": "8"
}

error when deploy

⚠  functions[ssrnuxt]: Deployment error.
Function load error: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/nuxt/lib/core/module.js:14
  async ready() {
        ^^^^^

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/user_code/node_modules/nuxt/lib/core/index.js:2:16)


Functions deploy had errors. To continue deploying other features (such as database), run:
    firebase deploy --except functions

Version info

firebase-tools: 4.0.2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 16 (4 by maintainers)

Most upvoted comments

I’m having a similar issue except I still get the warning: Warning: You're using Node.js v8.11.1 but Google Cloud Functions only supports v6.11.5.

Also, the final console output reads: ReferenceError: exports is not defined


firebase-tools: v5.6.0

package.json:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~5.12.1",
    "firebase-functions": "^1.0.3"
  },
  "devDependencies": {
    "eslint": "^4.12.0",
    "eslint-plugin-promise": "^3.6.0"
  },
  "engines": {
    "node": "8"
  },
  "private": true
}

i don’t like firebase need us to use nodejs v6 and v8.

@jennmueng I started another issue here https://github.com/firebase/firebase-functions/issues/421 but quickly closed it.

import isn’t supported by any version of node!

Remove that line, and/or just make a really basic function and try deploying it. See if it goes to Functions as a Node 8 function.

see my thread for details on eslintrc.json and make sure the engines setting is 8 in package.json.

But to repeat, sadly, import isn’t available in Node 8.

and some further info after I run firebase serve

i functions: Preparing to emulate functions. Warning: You’re using Node.js v8.9.0 but Google Cloud Functions only supports v6.11.5. ⚠ functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory. ⚠ functions: Error from emulator. Error occurred while parsing your function triggers.

Node v8.9.0 is what fixed my issue(s)

		nvm install v8.9.0
		nvm alias default v8.9.0

Looks like I’m stuck at the same spot @leads is

I’ve used nvm to use node v8.9.0, have reinstalled both firebase-tools and @google-cloud/functions-emulator with both yarn global and npm -g but I still receive the exact same error, along with the warning Warning: You're using Node.js v8.9.0 but Google Cloud Functions only supports v6.11.5..

I looked at @google-cloud/functions-emulator version 1.0.0-beta.5 and this error message has been removed, so why does it still show?

On Deploy:

i  deploying functions
✔  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing app directory for uploading...

Error: Error occurred while parsing your function triggers.

/Users/jennmueng/Documents/Tour-Backend/app/index.js:4
import * as functions from 'firebase-functions';
^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at /Users/jennmueng/.nvm/versions/node/v8.9.0/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15

On Serve:

i  functions: Preparing to emulate functions.
Warning: You're using Node.js v8.9.0 but Google Cloud Functions only supports v6.11.5.
⚠  functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
⚠  functions: Error from emulator. Error occurred while parsing your function triggers.

/Users/jennmueng/Documents/Tour-Backend/app/index.js:4
import * as functions from 'firebase-functions';
^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at /Users/jennmueng/.nvm/versions/node/v8.9.0/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15

This has been really frustrating…

@laurenzlong Seems like I did not have the latest CLI.

After running npm install -g firebase-tools and deploying it seems like the functions are runing Node.js 8.

Thanks!