a month ago
trying to deploy next.js v16 but deployment fails due to node version
next.js v16 now requires node c20+ (https://nextjs.org/blog/next-16#breaking-changes-and-other-updates) , and i even set RAILPACK_NODE_VERSION env to 22 but it still thinks i am using node 18 for some reason =(
Attachments
3 Replies
a month ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Next.js Service Fails on Startup (SIGTERM) - Even Clean Next.js App Affected
🧵 "Error: Project Token Not Found When Deploying with Railway CLI in GitHub Actions"
If you find the answer from one of these, please let us know by solving the thread!
a month ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open sarahkb125 • about 2 months ago
a month ago
Next.js version 16 now requires Node.js version 20 or higher to build and run. Railway currently uses Node 18 by default, which causes the deployment to fail.
Below is the complete solution to fix the problem:
1. Update the Node version in package.json
Open the package.json file and add the following section if it’s not already there:
"engines": {
"node": "22.x"
}
This tells Railway to use Node.js version 22 for the build process.
2. Add an .nvmrc file
In the root of the project (same place as package.json), create a file named .nvmrc and add:
22
This helps both locally and during deployment to ensure Node.js 22 is used.
3. Set the environment variable on Railway
In the Railway dashboard:
Go to the project service
Open the “Variables” tab
Add a new variable:
RAILWAY_NODE_VERSION = 22
Alternatively, you can use:
NODE_VERSION = 22
Do not use RAILPACK_NODE_VERSION — it is not a valid variable.
4. Clear build cache and redeploy
Railway sometimes caches previous builds that used Node 18. To fix this:
Go to the “Deployments” section in Railway
Click “Clear cache & redeploy”
Or, make a small change in your project (for example, update the README file), commit it, and push again. This will trigger a fresh deployment.
5. Verify build logs
After redeploying, open the build logs in Railway and confirm that it says:
Using Node.js version: 22.x
If it still shows Node 18, double-check the package.json, .nvmrc, and environment variable settings.
After completing these steps, the Next.js 16 project will build and deploy successfully on Railway using Node.js 22.
sumon9836
Next.js version 16 now requires Node.js version 20 or higher to build and run. Railway currently uses Node 18 by default, which causes the deployment to fail.Below is the complete solution to fix the problem:1. Update the Node version in package.jsonOpen the package.json file and add the following section if it’s not already there:"engines": {"node": "22.x"}This tells Railway to use Node.js version 22 for the build process.2. Add an .nvmrc fileIn the root of the project (same place as package.json), create a file named .nvmrc and add:22This helps both locally and during deployment to ensure Node.js 22 is used.3. Set the environment variable on RailwayIn the Railway dashboard:Go to the project serviceOpen the “Variables” tabAdd a new variable:RAILWAY_NODE_VERSION = 22Alternatively, you can use:NODE_VERSION = 22Do not use RAILPACK_NODE_VERSION — it is not a valid variable.4. Clear build cache and redeployRailway sometimes caches previous builds that used Node 18. To fix this:Go to the “Deployments” section in RailwayClick “Clear cache & redeploy”Or, make a small change in your project (for example, update the README file), commit it, and push again. This will trigger a fresh deployment.5. Verify build logsAfter redeploying, open the build logs in Railway and confirm that it says:Using Node.js version: 22.xIf it still shows Node 18, double-check the package.json, .nvmrc, and environment variable settings.After completing these steps, the Next.js 16 project will build and deploy successfully on Railway using Node.js 22.
a month ago
Thank you!
