ReferenceError: Request is not defined
Answered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
i was using next@13.5.6 and everything was working fine, just installed the latest next (v14) and it started to give this error
the problem exits with and without turbo
exits with next@14.0.1-canary.1
the problem exits with and without turbo
exits with next@14.0.1-canary.1
Answered by Orinoco Crocodile
This can be fixed by upgrading the node version
use to have v16.16.0 upgrading to v20.9.0 fixed the issue.
use to have v16.16.0 upgrading to v20.9.0 fixed the issue.
73 Replies
not happening for me in Next.js 14.0.0, can you try to isolate the error and provide sufficient information?
At least some short code snippets related to the error will be appreciated
At least some short code snippets related to the error will be appreciated
Orinoco CrocodileOP
its quite strange cause its not showing any errors in that file uk
Where are you referencing
NextRequest?Orinoco CrocodileOP
nope
im not using nextrequest at all
Then I might need a minimal reproducible repo to find the cause of error
Orinoco CrocodileOP
i have it on github
give me your email ill add
if thats fine with you
a private repo?
Orinoco CrocodileOP
yea
it'll better if you turn it into a public repo (or your company doesn't allow it?)
Orinoco CrocodileOP
ah
i will make it public
wait
i dm you the repo
well it works great, maybe you have to delete your
.next folder and try againprobably some build cache problems in my opinion
Orinoco CrocodileOP
still same
you using npm?
to install packages?
yes
Orinoco CrocodileOP
i used pnpm
because lock file doesn't exist at all
@fuma well it works great, maybe you have to delete your `.next` folder and try again
Orinoco CrocodileOP
same problem
you should commit your lock file to github, I don't find a lock file anywhere
Orinoco CrocodileOP
okay i will, im deleting packages with
npx npkill and deleting .next and going to try to use npm lets see if it workspnpm worked for me tho, surely there's a problem with your lock file
I literally ran
pnpm import and it workedOrinoco CrocodileOP
actually i dont have a lock file
well... 100% skill issue, did you run
pnpm i?Orinoco CrocodileOP
yea
like ofc
it was working well before
i installed the latest next
and it broked
then where is your lock file?
run
pnpm i and commit your lock file to githubOrinoco CrocodileOP
pnpm dont generates lock file
wait lol
just remembered i had set the lockfile to false
@fuma run `pnpm i` and commit your lock file to github
Orinoco CrocodileOP
pushed the
lockfile to githubWell, some problems with your dependency versions, ^9 actually means 9.0.0, which usually contains unlying bugs.
Secondly, you have several typescript errors in your project. Just fix it and it should be fine.
I upgraded some of them, fixed invalid typescript code and the build worked with no errors. So I'd say it's other problems instead of
Secondly, you have several typescript errors in your project. Just fix it and it should be fine.
I upgraded some of them, fixed invalid typescript code and the build worked with no errors. So I'd say it's other problems instead of
NextRequestmake sure enable lock file next time, package managers without lock file is just unbearable
@fuma Well, some problems with your dependency versions, ^9 actually means 9.0.0, which usually contains unlying bugs.
Secondly, you have several typescript errors in your project. Just fix it and it should be fine.
I upgraded some of them, fixed invalid typescript code and the build worked with no errors. So I'd say it's other problems instead of `NextRequest`
Orinoco CrocodileOP
what you mean by dependency version 9?
in your package.json
Orinoco CrocodileOP
im new to typescript lol idk how to use it properly
i will check
That's not a typescript problem to be honest
There's many dependencies with a version only has one digit, I opened a PR for you
Orinoco CrocodileOP
ah
thanks a lot man
it still gives the same error 😦
@fuma Click to see attachment
remove
.next and node_modules, run pnpm i againOrinoco CrocodileOP
i did
if it works on linux, should work on every device/platform I suppose
not to lie, your vercel build even works: https://github.com/vaibhav-OP/peerLift/pull/1#issuecomment-1783758459
have you did
git pull?Orinoco CrocodileOP
@fuma have you did `git pull`?
Orinoco CrocodileOP
ofc i did
likely it only happens locally, on your computer - so I have literally no idea how to fix an issue that I can't reproduce 

Orinoco CrocodileOP
ig i will have to downgrade again for now
sure, at least this can temporarily fix your problem
Orinoco CrocodileOP
yup downgrading to older version makes it work fine as before
anyways can i make my repo private again if you dont mind?
of course, as your question is solved
Orinoco CrocodileOP
thanks again
Orinoco CrocodileOP
This can be fixed by upgrading the node version
use to have v16.16.0 upgrading to v20.9.0 fixed the issue.
use to have v16.16.0 upgrading to v20.9.0 fixed the issue.
Answer