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

There is a TypeError saying URL is not a constructor, from gaxios dependency. Someone please help me. #688

Open
ManojaD2004 opened this issue Apr 16, 2024 · 12 comments

Comments

@ManojaD2004
Copy link

I have used google-auth-library, JWT auth for auth. Just yesterday it was working, today it is not.

https://theoephraim.github.io/node-google-spreadsheet/

Followed everything that was there in this docs. Also I’m using nextjs.

@gusintheeshell
Copy link

Same here, using Cypress

@nikfakel
Copy link

nikfakel commented Apr 22, 2024

Same here. I found out that google-auth-library cause this problem. It has dependency gaxios and invoke method https://github.com/googleapis/gaxios/blob/main/src/gaxios.ts#L191 with uppercase method URL, but it invoked in lowercase. I changed it directly in node_modules and it works. Now we need to wait for fix from google

@v29neil
Copy link

v29neil commented May 1, 2024

Any update on this fix ?
Facing this issue -

Error appending row: TypeError: url_1.URL is not a constructor
    at Gaxios._Gaxios_urlMayUseProxy (gaxios.js:274:23)
    at Gaxios._Gaxios_prepareRequest (gaxios.js:398:105)
    at Gaxios.request (gaxios.js:104:99)
    at DefaultTransporter.request (transporters.js:65:30)
    at GoogleToken._GoogleToken_requestToken (index.js:241:42)
    at GoogleToken._GoogleToken_getTokenAsyncInner (index.js:180:97)
    at GoogleToken._GoogleToken_getTokenAsync (index.js:160:173)
    at GoogleToken.getToken (index.js:110:102)
    at JWT.refreshTokenNoCache (jwtclient.js:173:36)
    at JWT.refreshToken (oauth2client.js:166:24)
    at JWT.getRequestMetadataAsync (oauth2client.js:312:28)
    at JWT.getRequestMetadataAsync (jwtclient.js:95:26)
    at JWT.getRequestHeaders (oauth2client.js:275:37)
    at U (index.mjs:37:21941)
    at C._setAxiosRequestAuth (index.mjs:37:23000)
    at async Axios.request (Axios.js:49:14)
    at async C.loadInfo (index.mjs:37:25258)

@MrBadIvan
Copy link

Had the same issue, changed version to 9.7.0 and it works.
(thanks for the hint that the issue happened 3 weeks ago)

@TimKraemer
Copy link

Same here. I found out that google-auth-library cause this problem. It has dependency gaxios and invoke method googleapis/gaxios@main/src/gaxios.ts#L191 with uppercase method URL, but it invoked in lowercase. I changed it directly in node_modules and it works. Now we need to wait for fix from google

@nikfakel can you please describe what you changed directly in node_modules?

Had the same issue, changed version to 9.7.0 and it works.

This doesn't fix it for me - @MrBadIvan did you do something extra except setting it to 9.7.0 and then npm / yarn install again? - I checked the package.json in node_modules and it's 9.7.0 but it's still creating the same Error.

@nikfakel
Copy link

@TimKraemer I changed this

  • const candidate = new url_1.URL(url);
  • const candidate = new url_1.Url(url);

And then I saved changes with patch-package, so CI/CD can keep this changes too

Now I got that this is no some bug, this package has to work on NodeJS and not considered to work in browser. So you can use just as is.

@MrBadIvan
Copy link

did you do something extra except setting it to 9.7.0 and then npm / yarn install again?

Nope =/

@ManojaD2004
Copy link
Author

Hey, I fixed it. Sorry for my late reply.

Basically I just copied the code and ran it in nodejs, instead of client side javascript. And it worked perfectly. 👍

Note: I still managed to run this on nextjs, not on pages though, but in the form of an api.

@TimKraemer
Copy link

@TimKraemer I changed this

  • const candidate = new url_1.URL(url);

  • const candidate = new url_1.Url(url);

Thank you! This is the only thing, that worked for me (I also had to remove my .next folder to kill the cached module).

@uzumis
Copy link

uzumis commented May 23, 2024

First of all. I tried to use patch-package to manage the error. But i dunno I'm using for Adobe Experience Manager purposes, but still having the gaxios URL typo.

Any updates of this issue?

@nikfakel
Copy link

@uzumis I use command (in package.json "scripts" to start server like this "dev": "npx patch-package && next dev"
before it I created patch with patch-package

@uzumis
Copy link

uzumis commented May 24, 2024

@nikfakel Works like a charm.

before the patch package i use npm clean first to assure the patch will be applied with no problem.
My issue is solved for now.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants