functions-samples icon indicating copy to clipboard operation
functions-samples copied to clipboard

convert-audio function error

Open inglesuniversal opened this issue 4 years ago • 5 comments

i deploying functions i functions: ensuring necessary APIs are enabled... ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

TypeError: require(...) is not a function at Object. (/Users/username/Firebase/functions/index.js:19:45) at Module._compile (internal/modules/cjs/loader.js:1147:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10) at Module.load (internal/modules/cjs/loader.js:996:32) at Function.Module._load (internal/modules/cjs/loader.js:896:14) at Module.require (internal/modules/cjs/loader.js:1036:19) at require (internal/modules/cjs/helpers.js:72:18) at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15 at Object. (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:53:3) at Module._compile (internal/modules/cjs/loader.js:1147:30)

I am following the instructions provided and I am getting the error shown above.

Can you provide an idea on what could fix this issue?

Regards

inglesuniversal avatar Apr 11 '20 17:04 inglesuniversal

I had exactly the same problem. You need to change your require code for @google-cloud/storage to something like the following:

const { Storage } = require('@google-cloud/storage');
const gcs = new Storage();

nefarioustim avatar Apr 14 '20 04:04 nefarioustim

Sorry to clutter this page:

I followed your suggestion and got this...

functions[generateMonoAudio(us-central1)]: Deployment error. Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "npm_installhad stderr output:\n/workspace/node_modules/ffmpeg-static/install.js:29\n url = new URL(url)\n ^\n\nReferenceError: URL is not defined\n at normalizeS3Url (/workspace/node_modules/ffmpeg-static/install.js:29:3)\n at Object.<anonymous> (/workspace/node_modules/ffmpeg-static/install.js:38:3)\n at Module._compile (module.js:653:30)\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 Function.Module.runMain (module.js:694:10)\n at startup (bootstrap_node.js:204:16)\n at bootstrap_node.js:625:3\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! [email protected] install:node 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-14T07_36_42_305Z-debug.log\n\nerror: npm_install` returned code: 1", "errorType": "InternalError", "errorId": "A0CF0542"}}

`

inglesuniversal avatar Apr 14 '20 07:04 inglesuniversal

URL is not defined either suggests you've not required URL or that you're using an older version of Node. Check the package.json for your functions and change the engines setting like so:

  "engines": {
    "node": "10"
  },

nefarioustim avatar Apr 14 '20 09:04 nefarioustim

Both solutions worked perfectly.

joe-pellegrino avatar Apr 22 '20 13:04 joe-pellegrino

I'll change the parameter to node 10 and I will let you know... THANKS for your AWESOME help

inglesuniversal avatar Apr 22 '20 17:04 inglesuniversal