ReferenceError: Request is not defined -while setting up sveltekit project
I just setup a fresh sveltekit project, when I opened the localhost it shows me the error above in the browser.
No error in terminal console.
node version using - v20.12.1
And also while creating a Vue project I get this error.
command:
npm create vue@latest
ouptut:
Are these errors interlinked somehow? How to solve it?50 Replies
Request is not defined definitely sounds like a Node version issue. I'm like 95% sure something changed in versions with node about how the Request package was built and then it was removed. You may need to use Node 18
Using 20.12.1
I reinstalled nvm
But still didn't work
if you use nvm you could just install a v18 and check that, but the way Requests are used changed between 16 -> 18... so if you're on 20........................................................... i shall look more
assuming your machine is on 20? is your package also on 20?
they can definitely be mismatched
I tried to setup fresh project with 20.12.1
Still showing the error
when you run
nvm -v
in your project, what does that say?1.1.12
:FacePalm: i definitely thought of one thing and asked a different thing
Happens
have you done like
nvm use v20.12.1
in your project?Yes sir
:pepeSad:
๐ญwhy meeeee
not sure it is you
could very well be an issue with sveltekit or vite or something else especially if its a fresh build
I mean why I'm the victim of this problem
I can setup a vue project either
never happens in React >:)
Cant
*
can you try downgrading node to a stable v18 version and see if that works?
okk
only for u ๐
are you checking node version in the same terminal as you're running the project? AKA not using the terminal for
nvm list
but using the vscode terminal to run the projecti googled both of the errors and both seemed to resolve on v18 so my brain says "do that" ๐
also definitely worth double checking that the versions are correct in the vsc terminal
though they should match up
well i checked on every terminal
yes i checked on vsc termianl
already did, they match everywhere even in sys32 dir and even in project folder
why are you trying to do this on windows, instead of wsl?
the real question is why not mac ๐
jk
because it costs an intel and a leg
not an arm, because it already has one
thats a big brain response
maybe its just me but for whatever reason v20 causes issues ๐ฆ
i used it in a debian vm with version 21
how come it works fine on my friends system
and it didnt cause any issues
im installing version 18 rn btw,
18.16.1
we actually deleted a docker image on v20 because of a severe CVE and then it was determined that CVE messed up their flag
good question
have you heard of docker?
18.16.1 is my favorite ๐
yup, but dont want to get into it
rn
don't get into it, the very concept of docker should be an answer for that question
besides, why do wsl when you can use the new prevew version of dev home on windows
the what?
Dev Home for Windows Developers
Dev Home is a new control center for Windows providing the ability to track your workflows and coding tasks using customizable widgets, set up your dev environment, connect to your developer accounts and tools (such as GitHub), and install apps and packages all in one place.
slightly clunky but works pretty well
the definition of Windows?
true. this is not the case on either of my Macs
looks kinda interesting
still same error ๐ข
its the logs
what do you mean same error? like one of the ones above?
yes sir
you may not be alone https://github.com/vitejs/vite/discussions/15798
GitHub
ReferenceError: Request is not defined at getRequest (file:///....
Describe the bug After running npm run dev... this error persists in the localhost browser... site will not load. ReferenceError: Request is not defined at getRequest (file:///../node_modules/@svel...
just skip past the "steps to reproduce" section
I can understand his feelings
wrong one lol
https://github.com/vercel/next.js/discussions/47648
GitHub
ReferenceError: Request is not defined ยท vercel next.js ยท Discussio...
Summary Hi, Suddenly my code is giving this error when deploying on Vercel. I tried tons of things to fix it but nothing seems to work. When I run it locally whether with "next dev", &quo...
seems like there might be some steps in that one that could potentially solve it, but i'm not a svelte dev (just a scummy ol React dev) so i'm a bit beyond my depths when it comes to that library ๐ฌ