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.

Can't find variable _ after upgrading to Next 12.3

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64 Binaries: Node: 16.13.1 npm: 6.14.8 Yarn: 1.22.19 pnpm: N/A Relevant packages: next: 12.3.0 eslint-config-next: 11.1.2 react: 17.0.2 react-dom: 17.0.2

What browser are you using? (if relevant)

Reproduced with Firefox 104.0.1 and Safari 15.6.1

How are you deploying your application? (if relevant)

No response

Describe the Bug

After upgrading to Next 12.3 this morning, I’ve immediately had a console error saying “Can’t find variable _”.

I’ve debugged my code, because it made no sense. I’ve upgraded Typescript, no change.

I’ve finally fixed it by finding the _ variable that was created after compilation, create a new named variable and use it.

My code used to be:

switch (component.type) {

it’s now:

let componentType: string = component.type;
switch (componentType) {

It is a silly thing, but I’ve lost plenty of time because of this, and I’m still unclear what’s the root cause.

Expected Behavior

No error after compilation.

Link to reproduction

It’s a private repo

To Reproduce

Hard to say how to reproduce outside of the code that is provided above. Let me know if I can provide anything more helpful.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
SukkaWcommented, Sep 9, 2022

Just disscussed the issue with some SWC contributors. It seems that issue might be related with SWC’s recent generator transpiling changes.

2reactions
balazsorban44commented, Sep 9, 2022

Using the reproduction from #40405 indeed, it seems to be an SWC issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade Guide - Next.js
Upgrade Guide. Upgrading from 12 to 13. To update to Next.js version 13, run the following command using your preferred package manager:
Read more >
Next.js 12.3 Overview: Improved Fast Refresh ... - YouTube
Next.js 12.3 introduces several improvements to your React development workflow, including hot reloading environment and configuration files ...
Read more >
Next.js Tutorial for Beginners (Getting Started) | Stack Diary
When developing an application with multiple pages, some page elements, such as Headers and Footers, will (almost) always remain the same.
Read more >
Module not found: Can't resolve 'fs' in Next.js application
For me, the problem was the old version of the node. js installed. It requires node. js version 14 and higher.
Read more >
Final Cut Pro release notes - Apple Support
Before installing a Final Cut Pro update, verify that your system still ... Improves reliability when using the Select Next Clip command.
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