0
votes

Background: I recently (attempted) to add Taiko to my Firebase web app. Taiko is a browser-automation npm package, like Puppeteer. Maybe relevant: it downloads Chromium to work.

Problem: now none of my functions will deploy.

Question beyond getting past this specific issue, my more general question is, "what am I missing in this workflow?" / "How can I avoid this problem in the future?"

Error Message: (bold mine, highlighting stuff that might be relevant)

  • Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\n/workspace/node_modules/fs-extra/lib/mkdirs/make-dir.js:86\n } catch {\n ^\n\nSyntaxError: Unexpected token {\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at Module._compile (module.js:617:28)\n at Object.Module._extensions..js (module.js:664:10)\n at Module.load (module.js:566:32)\n at tryModuleLoad (module.js:506:12)\n at Function.Module._load (module.js:498:3)\n at Module.require (module.js:597:17)\n at require (internal/module.js:11:18)\n at Object. (/workspace/node_modules/fs-extra/lib/mkdirs/index.js:3:44)\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! [email protected] install: `node lib/install.js`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the [email protected] install script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2020-04-19T14_36_20_217Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "02C3A7B5"}}

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"
  },
  "engines": {
    "node": "8"
  },
  "dependencies": {
    "firebase-admin": "^8.10.0",
    "firebase-functions": "^3.3.0",
    "node-fetch": "^2.6.0",
    "stripe": "^7.14.0",
    "taiko": "^1.0.6",
    "bufferutil": "^4.0.1",
    "utf-8-validate": "^5.0.2"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.1.6"
  },
  "private": true
}

What I've done so far:

  • created a Taiko test function in index.js, requireing Taiko.

  • added Taiko to package.json

  • ran npm install in functions folder

  • received message npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

  • following which, npm installed both of the above packages in /functions

This is the same basic procedure I followed to create a Stripe function in my index.js, and had no issues.

EDIT: Taiko 1.07, Node 12.16.2, npm 6.9.0, firebase-tools cli 8.1.1

Any insights appreciated!

1

1 Answers

1
votes

From the Taiko team on Github:

This error generally happens on version < node 10 indirectly because of the fs-extra package. Firebase cloud functions uses node 8 by default. Please try setting the expermental node 10 as mentioned in the documentation at https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version

So, the specific answer was to set the Node engine to "10" in the Firebase project package.json file.

And, the more general answer to "what I am missing in this workflow", is

  • when running packages in a remote environment, make sure that the runtimes of that environment match up with your local development environment, or the behavior might differ.

  • Use the appropriate version of node for the packages in your project, not necessarily the latest one.