Matthew C.
—When you run your Next.js application locally or when deploying it on a platform like Vercel, you may get the following error:
ReferenceError: Request is not defined
You may also get a more useful and specific error:
You are using Node.js 16.13.1. For Next.js, Node.js version >= v18.17.0 is required.
As described in the second error message, this error is caused by not having the required Node.js version.
Install the required Node.js version. You can use a tool like Node Version Manager (nvm) to simplify using different versions of Node on your device. nvm is a command line tool that allows you to quickly install and use different versions of Node. It allows you to use different Node versions for different projects.
To install it follow the nvm installation guide. If you use Windows, you can install nvm using WSL (Windows Subsystem for Linux). It should also work with GitBash (MSYS) or Cygwin.
Once you’ve installed nvm, you can install a specific version of Node:
nvm install 18.17.0
You can then use the use
command to use a specific Node version:
nvm use 18.17.0
Note that you should make sure that your project dependencies work with the new Node version. This may require updating your project’s dependencies.
If you are using Vercel to deploy your Next.js application, and you have an issue with the Node.js version, you can change the Node.js version in your Vercel Dashboard Project Settings under the Node.js Version setting. By default, new projects use the latest Node.js LTS version available on Vercel.
You can define the major node
version in the engines
section of your project’s package.json
to override the Vercel dashboard project settings.
To check which Node version your Vercel deployment is using, you can run node -v
in the build command, or you can log process.version
.
Make sure that the Node version in your local environment and in your deployed environment match to minimize issues caused by different Node.js versions such as dependencies having different Node.js version requirements.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at compliance@sentry.io.
If you are a California resident, see our Supplemental notice.