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.

Cannot destructure property `publicRuntimeConfig` of 'undefined' or 'null'. (v9.5.0)

See original GitHub issue

Bug report

After upgrading from 9.4.4 to 9.5.0 I get an error after building (in dev mode all works fine):

Cannot destructure property `publicRuntimeConfig` of 'undefined' or 'null'.

Code:

import getConfig from "next/config";
const { publicRuntimeConfig } = getConfig()

System information

  • OS: macOS
  • Browser: chrome
  • Version of Next.js: 9.5.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:12

github_iconTop GitHub Comments

4reactions
gushigueracommented, Mar 3, 2021

Oke, so I found the situation when this is happening. I use next-transpile-modules to import modules from a different component package. But when I try to call getConfig inside a component in a different package it fails, a workaround is passing the config to the Component.

I also have next-transpile-modules in my next.config.js and running into this issue when running my tests? Any recommendations?

2reactions
kogaicommented, Oct 12, 2020

I’ve got the same error too, when I’ve introduced getStaticProps. it occurred when next dev subcommand executed, but the next build && next start did not the case.

Version of Next.js: 9.5.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js Cannot destructure property 'publicRuntimeConfig' of ...
We have this function below which is stored in common folder to be used for both client and server, and it fails when...
Read more >
[next.js] Cannot destructure property 'BACKEND_URL ... - GitLab
publicRuntimeConfig ' as it is undefined. I have an app that's written in next.js, that has env variables. App works perfectly locally (...
Read more >
Contribute to vercel/next.js · GitHub
5. [Hapi + Nextjs] custom-server-hapi got a [ERR_HTTP_HEADERS_SENT]: Cannot ... Cannot destructure property `publicRuntimeConfig` of 'undefined' or 'null'.
Read more >
Next.js error: Cannot destructure property? : r/learnjavascript
AuthContext: {$$typeof: Symbol(react.context), _calculateChangedBits: null, _currentValue: undefined, _currentValue2: undefined, _threadCount: 0 ...
Read more >
cannot read property 'usecontext' of null nextjs - You.com
I think your bug related to SSR. If you run the code with SSR, the initializeState will receive undefined. But initializeState should be...
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