`ERROR TypeError: n is not a constructor` with `google-spreadsheet` in a function

Hi,

I wrote a feedback.js function that uses google-spreadsheet. However, when this function is executed, I get the following runtime error:

11:12:57 AM: 0627b9a4 ERROR  TypeError: n is not a constructor
    at /var/task/src/lambda/feedback.js:9:341040
    at Generator.next (<anonymous>)
    at i (/var/task/src/lambda/feedback.js:9:340669)
    at o (/var/task/src/lambda/feedback.js:9:340872)
    at /var/task/src/lambda/feedback.js:9:340931
    at new Promise (<anonymous>)
    at /var/task/src/lambda/feedback.js:9:340812
    at o (/var/task/src/lambda/feedback.js:9:341458)
    at s (/var/task/src/lambda/feedback.js:9:340968)
    at /var/task/src/lambda/feedback.js:9:341543

It’s for the feedback widget at the bottom of Quickstart.

The source code is in feedback.ts in this PR: Add docs feedback widget. by mikenikles · Pull Request #516 · gitpod-io/website · GitHub

The function worked before I added the google-spreadsheet dependency, so it’s likely something with that function and/or the babel config. If anyone has any ideas, I’d love to hear them :slight_smile: .

Thanks,

Mike

hi mike, sorry this has been lingering without any responses for a bit. Have you been able to make any progress? this goes a bit beyond what we are normally able to debug, but i am happy to leave this thread open for others to chime in if you’d like.

Hey, I haven’t figured it out yet, but saw that Netlify Functions now support Typescript natively. I may try this and get rid of babel in the process to see if that makes a difference at all.

As a last resort, I will implement it in SvelteKit rather than a separate Netlify function. I think it’s ok to close this thread.

For anyone ending up here, using native Typescript support works like a charm.

As a nice side effect, I was able to completely remove Babel and with it, ~5,000 lines of package-lock.json content.

Details in PR Use native Typescript support for Netlify functions. by mikenikles · Pull Request #622 · gitpod-io/website · GitHub.

2 Likes

thanks for sharing, @mikenikles ! sounds like a nice improvement :slight_smile: