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.

`ReferenceError: __DEV__ is not defined` after update to `3.4.5` with `Next.js` app

See original GitHub issue

Intended outcome: After updating to 3.4.5, on our Next.JS@11.1.0 app, we expect that our app launch with any problem.

Actual outcome: On our production bundle (everything works fine on dev mode), we got this message on runtime ReferenceError: __DEV__ is not defined. We had the same problem with the 3.4.0, but it has been fixed on 3.4.1 following this issue #8557. Something may have changed between 3.4.4 and 3.4.5, and still here on 3.4.8.

How to reproduce the issue: Our repo is private but let me know if you want me to setup a simple exemple with NextJS / Apollo to have some tests. We have this problem on our every nextJS app using @apollo/client>3.4.4.

Versions

 System:
    OS: macOS 11.5.2
  Binaries:
    Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm
  Browsers:
    Chrome: 92.0.4515.159
    Firefox: 91.0.1
    Safari: 14.1.2
  npmPackages:
    @apollo/client: 3.4.5 => 3.4.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:27 (9 by maintainers)

github_iconTop GitHub Comments

12reactions
oyedcommented, Aug 28, 2021

Hmm, I just found this issue - this just started happening to me after upgrading to v3.4.10 using Vite & Vue.

11reactions
davidbarralcommented, Sep 9, 2021

Vite users can use a function in vite.config.js and set a define option:

export default ({ mode }) => ({
  define: {
    "__DEV__":  (mode === "development").toString(),
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >
Window is not defined in Next.js React app - Stack Overflow
The error occurs because window is not yet available, while component is still mounting. You can access window object after ...
Read more >
How to Fix "localStorage is not defined" in Next.js
You've tried to use localStorage in your Next.js application and you're getting the following error: ReferenceError: localStorage is not defined ...
Read more >
Fixing Next js "ReferenceError: document is not defined"
The error is thrown because document is only available inside the browser and not on the server. Next js executes this code on...
Read more >
Getting Referenceerror: Appearance Is Not Defined - ADocLib
ReferenceError : DEV is not defined after update to 3.4.5 with Next.js app If everything looks good those changes will probably get.
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