Hi! I created a new project with npx create-next-app@latest and then immediately ran npm run dev.
I got the following error:
../node_modules/next/dist/server/web/spec-extension/request.js:28
class NextRequest extends Request {
^
ReferenceError: Request is not defined
at Object.<anonymous> (.../node_modules/next/dist/server/web/spec-extension/request.js:28:27)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at Module.mod.require (.../node_modules/next/dist/server/require-hook.js:64:28)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (.../node_modules/next/dist/server/web/spec-extension/adapters/next-request.js:37:18)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
Node.js v17.4.0
So then I uninstalled all my node versions from my computer and reinstalled the latest one v20 using nvm. I also created another next app with npx create-next-app@13.4. Which was the one that mosh used. However I continue to get the same error.
My guess is that there is some version of node 17.4 in my machine and nextjs can’t detect the newest one I just installed.
Does anyone know how I can solve this?