Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: bundle problem when using googleapis #1709

Closed
daimalou opened this issue Aug 19, 2022 · 12 comments
Closed

🐛 BUG: bundle problem when using googleapis #1709

daimalou opened this issue Aug 19, 2022 · 12 comments
Labels
bug Something that isn't working internal Requires support from the Cloudflare Platform

Comments

@daimalou
Copy link

daimalou commented Aug 19, 2022

What version of Wrangler are you using?

2.0.26

What operating system are you using?

Windows

Describe the Bug

I am using two google official libraries to develope some features.

"google-auth-library": "^8.2.0",
https://github.com/googleapis/google-auth-library-nodejs

"googleapis": "^105.0.0",
https://github.com/googleapis/google-api-nodejs-client

I wirite node_compat = true on wrangler.toml, and then I run npm run start It says:

X [ERROR] Could not resolve "http2"
 node_modules/googleapis-common/build/src/http2.js:16:22:
    16 │ const http2 = require("http2");
         │                       ~~~~~~~
         ╵                       "./http2"

  The package "http2" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
@daimalou daimalou added the bug Something that isn't working label Aug 19, 2022
@JacobMGEvans
Copy link
Contributor

Found a similar issue on Clerk here: clerk/javascript#127 (comment)
and Fauna here: fauna/faunadb-js#649

@JacobMGEvans JacobMGEvans moved this to Untriaged in workers-sdk Aug 22, 2022
@Infinitay
Copy link

Has anyone found a solution to this issue? Facing this myself when trying to use the got (https://github.com/sindresorhus/got) package

@JacobMGEvans
Copy link
Contributor

JacobMGEvans commented Sep 2, 2022

Has anyone found a solution to this issue? Facing this myself when trying to use the got (https://github.com/sindresorhus/got) package

Are you utilizing the --node-compat flag or in wrangler.toml using node_compat = true?

Additionally if anyone can provide the Node versions they are utilizing, that would be helpful.

@Infinitay
Copy link

Infinitay commented Sep 3, 2022

Yes I have tried adding node_compat = true but it resulted in the same issue as OP. Actually, with the same package too of http2.

Node Version: v16.13.1

For the time being I refactored my code to use the native fetch rather than got.

@jspspike
Copy link
Contributor

jspspike commented Sep 6, 2022

We won't be able to fix this within wrangler but we've created an internal issue to try to improve node_compat within the workers runtime. We'll be closing this ticket for now

@jspspike jspspike closed this as completed Sep 6, 2022
Repository owner moved this from Untriaged to Done in workers-sdk Sep 6, 2022
@jspspike jspspike added the internal Requires support from the Cloudflare Platform label Sep 6, 2022
@pbteja1998
Copy link

Hi, is there any update on this?

I am trying to use wrangler2 with fauna and getting the same error saying Could not resolve "http2"

@MuhammedAO
Copy link

Hi, I'm experiencing this bug at the moment. was there any resolution to this?

@sbussard
Copy link

Same issue

@mujeeb-kalwar
Copy link

Same issue, I am using wrangler 3.13.1

@flyinvscode
Copy link

Same issue

@elizabethsiegle
Copy link

Same issue

@shonubijerry
Copy link

shonubijerry commented Aug 23, 2024

As a work around I have written a gist here to authenticate with GCP and query via API rather than the npm packages.

https://gist.github.com/shonubijerry/1c0a1deff5c74d42602ab726017da0ad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working internal Requires support from the Cloudflare Platform
Projects
None yet
Development

No branches or pull requests