0

I have currently 10 working functions in my firebase:functions. Now I try to create a pdf inside a rtdb-trigger-function. The problem is, as soon as I require pdfkit:

const pdfkit = require('pdfkit');

All of my functions can not be updated: Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.

I installed pdfkit via npm: npm install pdfkit This is the output:

npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 

up to date, audited 465 packages in 2s

52 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

This is my 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": "16"
  },
  "dependencies": {
    "busboy-firebase": "^1.0.7",
    "check-node-version": "^4.2.1",
    "firebase-admin": "^11.4.1",
    "firebase-functions": "^4.1.1",
    "mailgun": "^0.5.0",
    "node": "^16.1.0",
    "node-fetch": "^2.6.1",
    "nodemailer": "^6.6.1"
  },
  "devDependencies": {
    "@google-cloud/tasks": "^2.1.2",
    "@types/pdfkit": "^0.12.8",
    "busboy": "^1.6.0",
    "cors": "^2.8.5",
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.1.6",
    "pdfkit": "^0.13.0"
  },
  "private": true
}

What is wrong?

Thank you!

This is what I did:

  • Try node version 10,12,14,16
  • Installed node 16.4.0
  • npm install pdfkit
  • It looks like you're running on Node 18, while the PDF Kit only works on Node 16. See this post on how to change the Node version in your package.json: https://stackoverflow.com/a/70269965/209103 – Frank van Puffelen Jan 02 '23 at 15:11
  • I changed it to v. 16.0.0 after I execute firebase deploy --only functions I get this error: firebase deploy --only functions Firebase CLI v11.16.1 is incompatible with Node.js v16.0.0 Please upgrade Node.js to version ^14.18.0 || >=16.4.0 – David Anzenhofer Jan 02 '23 at 15:34
  • That sounds like you'll have to *downgrade* the Firebase CLI to a version that still supports Node 16. – Frank van Puffelen Jan 02 '23 at 15:52
  • I changed the version now to 16.4.0 and I do not get any warnings/errors when I install pdfkit: npm install pdfkit. Now after executing firebase deploy I get the same error: Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/doc... – David Anzenhofer Jan 02 '23 at 15:53

0 Answers0