question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'map' of undefined at Server.generateRoutes

See original GitHub issue

Bug report

Describe the bug

I’ve been using nextjs with typescript to build a web app (based off of the example at https://github.com/mui-org/material-ui/tree/master/examples/nextjs-with-typescript). However, when I deploy my app to an AWS elastic beanstalk instance, I get a strange error that breaks my app. next start does not run correctly. I cannot reproduce this locally, only when I deploy to AWS’s elastic beanstalk.

Stack trace:

> next start --port 8081

TypeError: Cannot read property 'map' of undefined
    at Server.generateRoutes (/var/app/current/node_modules/next/dist/next-server/server/next-server.js:257:36)
    at new Server (/var/app/current/node_modules/next/dist/next-server/server/next-server.js:81:49)
    at createServer (/var/app/current/node_modules/next/dist/server/next.js:2:133)
    at start (/var/app/current/node_modules/next/dist/server/lib/start-server.js:1:323)
    at nextStart (/var/app/current/node_modules/next/dist/cli/next-start.js:22:125)
    at commands.(anonymous function).then.exec (/var/app/current/node_modules/next/dist/bin/next:29:346)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-website@1.0.0 start: `next start --port 8081`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test-website@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

To Reproduce

Deploy nextjs app with typescript to elastic beanstalk instance

Expected behavior

The app should just run next start normally.

System information

  • OS: Node.js running on 64bit Amazon Linux/4.12.0
  • Version of Next.js: both 9.1.16 and 9.1.17

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

14reactions
timneutkenscommented, Jan 14, 2020

Please provide a full reproduction including all code. Just 2 files is not enough.

8reactions
timneutkenscommented, Jan 24, 2020

I will say one thing however, there’s a lot of issues I’ve been having with next.js and whenever I find the bug posted here the development team always seem to deny any issues.

We don’t deny issues. I’ve already spent over an hour on this particular issue without being able to reproduce as no reproduction was provided.

We ask for a reproduction so that we can add a test in our test suite to ensure it doesn’t happen again.

Eg in this case I’ve asked for a full reproduction 5 times and 1 time it was provided, tried to reproduce based on the steps provided and couldn’t reproduce so posted back. Didn’t hear back from anyone experiencing the issue since.

In this case, it’s not really a bug with next.js, but perhaps advising to clear the cache and rebuild would be more constructive than “Cannot reproduce. Next.js can do no wrong.”

Specifically “Next.js can do no wrong”

I’ve never said that, I’ve only asked for a reproduction so that we can actually solve the issue you’re experiencing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

typeError: Cannot read property 'map' of undefined (nextjs)
I just want to fetch this data. typeError: Cannot read property 'map' of undefined -> Error import styles from '../styles/ ...
Read more >
How to Prevent the TypeError: Cannot Read Property Map of ...
A guide on the root cause of 'cannot read map of undefined' as well as techniques and tools to prevent this error.
Read more >
cannot read property 'usecontext' of null nextjs - You.com
When I see no possible errors I got this nextjs project and it won't work cause of this server error saying useContext of...
Read more >
Fix the "Cannot read property 'map' of undefined" Error in React
In this post, we'll learn how to fix it. Why It's Happening. The variable you are trying to map over is undefined ....
Read more >
can not read property map of undefined | fetch in react using ...
Your browser can't play this video. Learn more. Switch camera ... can not read property map of undefined | fetch in react using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found