node-google-spreadsheet
node-google-spreadsheet copied to clipboard
There is a TypeError saying URL is not a constructor, from gaxios dependency. Someone please help me.
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.
Same here, using Cypress
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
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)
Had the same issue, changed version to 9.7.0 and it works. (thanks for the hint that the issue happened 3 weeks ago)
Same here. I found out that
google-auth-library
cause this problem. It has dependencygaxios
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.
@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.
did you do something extra except setting it to 9.7.0 and then npm / yarn install again?
Nope =/
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 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).
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?
@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
@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
I've also experienced this and apart from directly hardcoding a fix in node_modules
š, I didn't know what else to do. I will try patching the package as you suggested @nikfakel.
I did notice that it appeared to have been raised (and fixed?) already in this commit: https://github.com/googleapis/gaxios/pull/45/files#diff-1fbac0bfbd160f817d8a77140897b06cb53ff95f317bc9c3345afe4605fb3978
To fix it, if you look at the top of gaxios.ts
there are some helper functions to detect information about the environment in which it's running -it would be simple to add another similar function or maybe make use of hasWindow()
to work out whether to use the node URL module or window.url
.
Anyway, I thought about creating a pull request but I hesitated as it looked like it had at some point already been done - and maybe removed again for a reason?