ReferenceError: Request is not defined #47648
-
SummaryHi, 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", "vercel dev", "vercel build", it doesn't give any error. What could be causing this and what is the best way to debug it? Additional informationReferenceError: Request is not defined
at Object.<anonymous> (/vercel/path0/node_modules/next/src/server/web/spec-extension/request.ts:10:34)
at Module._compile (node:internal/modules/cjs/loader:1165:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
at Object.require.extensions.<computed> [as .js] (/vercel/path0/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1043:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1067:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/vercel/path0/node_modules/next/server.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1165:14) ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 18 replies
-
What version of Node.js have you got on your Vercel deployment? If it is 16.x, or less, then you should set it to 18.x, assuming that none of the packages you are ussing, require lower Node.js versions. Basically, you should have the same Node.js version, locally and on Vercel. Figuring out the Node version on Vercel: https://vercel.com/changelog/node-js-version-now-customizable-in-the-project-settings |
Beta Was this translation helpful? Give feedback.
-
To solve this on Windows: download the latest LTS version: https://nodejs.org/en/download To solve this in WSL 2 (Linux): Step1: First, let’s install Node Version Manager (nvm), which will enable us to manage Node.js versions easily.
Step2: With nvm installed, you can now check the available Node.js versions:
Step3: Now you will install the latest LTS version of Node in this case in 10/2023 it is 20.9:
Step4: Just to be sure, put the installed version as default
Step5: Check the Node version:
Step6: Be happy and nice coding |
Beta Was this translation helpful? Give feedback.
-
[Fixed] Just update your node js version nodejs -v // version 16 😢 |
Beta Was this translation helpful? Give feedback.
-
i face with same problem i have solution |
Beta Was this translation helpful? Give feedback.
-
Many Thanks after updating node version, issue resolved. |
Beta Was this translation helpful? Give feedback.
-
but it works with `sudo` |
Beta Was this translation helpful? Give feedback.
What version of Node.js have you got on your Vercel deployment? If it is 16.x, or less, then you should set it to 18.x, assuming that none of the packages you are ussing, require lower Node.js versions.
Basically, you should have the same Node.js version, locally and on Vercel.
Figuring out the Node version on Vercel: https://vercel.com/changelog/node-js-version-now-customizable-in-the-project-settings