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 'amp' of null

See original GitHub issue

When upgrading from next 8.0.3 to 8.1.0 I get the following error when compiling any page:

 [ error ] TypeError: Cannot read property 'amp' of null
     at Object.renderToHTML (/usr/app/enrola-webapp/node_modules/next-server/dist/server/render.js:169:33)
     at process._tickCallback (internal/process/next_tick.js:68:7)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
zomarscommented, Jul 13, 2019

In my case I solved like this:

const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')

const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app.prepare().then(() => {
  createServer((req, res) => {
    // Be sure to pass `true` as the second argument to `url.parse`.
    // This tells it to parse the query portion of the URL.
    const parsedUrl = parse(req.url, true) // <---- I DIDN'T PASS TRUE HERE
    const { pathname, query } = parsedUrl

    handle(req, res, parsedUrl)
  }).listen(3000, err => {
    if (err) throw err
    console.log('> Ready on http://localhost:3000')
  })
})
1reaction
elmassecommented, Jul 12, 2019

To add my 2 cents in here, I had the same issue with 8.1.0 and 9.x the root cause I found in my case was that url.parse returns the urlObject with query=null. Then any default value passed as ( query = {} ) was not defaulted to {} and then the check of query.amp in 9.x throws.

In my case I have a custom server, so it’s quite simple to fix it by just checking for null and making the default to {}.

Not sure thou how to reproduce this in a plain example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'map' of null - Stack Overflow
the answer is very simple: the type of the input isn't array type, it might be null or undefined . so that it...
Read more >
TypeError: Cannot read property 'map' of null in React.js
The "cannot read property 'map' of null" error occurs when we call the map() method on a null value, most often when initializing...
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 >
Type error: cannot read property 'map' of null - react JS
How have you defined products is still not clear. I can just guess that its initialized as null in your component and that...
Read more >
Fix the "Cannot read property 'map' of undefined" Error in React
The variable you are trying to map over is undefined . It will probably eventually be an array, but due to the asynchronous...
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