Unable to deploy minimal next js app

Hi, I am trying to deploy a minimal nextjs app to render.

I ran the following command: npx create-next-app --use-npm, then pushed that code to github, connected to a render web service and then immediately got a build error. Here is the event log:

May 18 07:04:08 AM  ==> Cloning from https://github.com/andersr/minimal-render-test...
May 18 07:04:08 AM  ==> Checking out commit d5a82f8b94f7d6420d37764d570a263e7e2872d4 in branch main
May 18 07:04:12 AM  ==> Running build command 'npm install && npm run build'...
May 18 07:04:35 AM  added 294 packages from 171 contributors and audited 301 packages in 22.95s
May 18 07:04:35 AM  
May 18 07:04:35 AM  126 packages are looking for funding
May 18 07:04:35 AM    run `npm fund` for details
May 18 07:04:35 AM  
May 18 07:04:35 AM  found 0 vulnerabilities
May 18 07:04:35 AM  
May 18 07:04:36 AM  
May 18 07:04:36 AM  > third-test@0.1.0 build /opt/render/project/src
May 18 07:04:36 AM  > next build
May 18 07:04:36 AM  
May 18 07:04:36 AM  uncaughtException /opt/render/project/src/node_modules/next/dist/compiled/undici/index.js:1
May 18 07:04:36 AM  (()=>{var __webpack_modules__={1900:(A,e,t)=>{"use strict";const{parseContentType:s}=t(4318);function getInstance(A){const e=A.headers;const t=s(e["content-type"]);if(!t)throw new Error("Malformed content type");for(const s of o){const o=s.detect(t);if(!o)continue;const r={limits:A.limits,headers:e,conType:t,highWaterMark:undefined,fileHwm:undefined,defCharset:undefined,defParamCharset:u
<LOTS OF MINIFIED CODE>
A[q]=false;if(IA.connectError.hasSubscribers){IA.connectError.publish({connectParams:{host:e,hostname:t,protocol:i,port:n,servername:A[w],localAddress:A[gA]},connector:A[AA],error:o})}if(o.code==="ERR_TLS_CERT_ALTNAME_INVALID"){s(A[F]===0);while(A[L]>0&&A[Y][A[K]].servername===A[w]){const e=A[Y][A[K]++];errorRequest(A,e,o)}}else{onError(A,o)}A.emit("connectionError",A[D],[A],o)}resume(A)}function emitDrain(A){A[T]=0;A.emit("drain",A[D],[A])}function resume(A,e){if(A[m]===2){return}A[m]=2;_resume(A,e);A[m]=0;if(A[v]>256)npm ERR! code ELIFECYCLE
May 18 07:04:36 AM  npm ERR! errno 1
May 18 07:04:36 AM  npm ERR! third-test@0.1.0 build: `next build`
May 18 07:04:36 AM  npm ERR! Exit status 1
May 18 07:04:36 AM  npm ERR!
May 18 07:04:36 AM  npm ERR! Failed at the third-test@0.1.0 build script.
May 18 07:04:36 AM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
May 18 07:04:36 AM  
May 18 07:04:36 AM  npm ERR! A complete log of this run can be found in:
May 18 07:04:36 AM  npm ERR!     /opt/render/.cache/_logs/2023-05-18T11_04_36_208Z-debug.log
May 18 07:04:36 AM  ==> Build failed 😞

This is a default nextjs app installed with npm.
My build command is: npm install && npm run build

Everything builds and runs locally with no issues.

Any ideas what the issue might be?

Hi Anders,

What version of node are you using locally? Can you ensure that you’ve specified the same version on Render as well? This can be done via the methods listed in this doc: https://render.com/docs/node-version

Let me know if that helps.

Best,

I am running node v16.14.0
I added node version

  "engines": {
    "node": ">=16 <17"
  }

And that fixed the issue. Thanks so much!

Nice, happy to hear that!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.