Next.js app throws an error on the server but not locally

Viewed 493

I have been developping a Next app for quite a while now.

After the build, my app works just fine locally, but throws this on the server:

TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at NextNodeServer.getEdgeFunctions (...node_modules/next/dist/server/next-server.js:656:23)
at NextNodeServer.generateCatchAllMiddlewareRoute (...node_modules/next/dist/server/next-server.js:991:22)
at NextNodeServer.generateRoutes (...node_modules/next/dist/server/base-server.js:464:41)
at new Server (...node_modules/next/dist/server/base-server.js:109:48)
at new NextNodeServer (...node_modules/next/dist/server/next-server.js:62:9)
at NextServer.createServer (...node_modules/next/dist/server/next.js:128:16)
at async ...node_modules/next/dist/server/next.js:137:31

IMO this error message isn't really explicit... The previous version of the worked just fine I changed it so much I don't really know where to look.

Of course I ran npm install btw.

I know that this is probably too little info to have a definite answer, but I have no idea of where I can look...

4 Answers

For us, the same thing occurred with our Next.JS applications running on AWS Beanstalk. After reverting Next.JS in the package.json to version 12.1.6 everything started working again.

Okay, basically deleted node_modules, cache, .next folder, etc. and made a new clean install then a new build and it seems to work.

My guess is that it have something to do with cache from previous builds...

Delete node_modules, cache, .next folder, etc. and made a new clean install then a new build.

It works for me and will work for you also

Related