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.

Next 12.2 ReferenceError: exports is not defined

See original GitHub issue

Verify canary release

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

Provide environment information

Next 12.2(-12.2.2)

Describe the Bug

I’m no longer able to import code with exports properly in Next 12.2

Expected Behavior

Next should properly bundle these files

Link to reproduction

https://github.com/hanford/12.2-exports

To Reproduce

Pull reproduction repo and try running on Next 12.2.0, you’ll see the following error: image

You can check out the working branch, which just has Next 12.1.6, after installing the older version the code will run without error.

Happy to provide more information if it’s helpful!

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:9
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
PizzaPetecommented, Jun 29, 2022

We’re running into the same thing. It was working before on version 12.1.6.

4reactions
system32uwucommented, Jul 3, 2022

Can confirm that this was working before 12.2, we use next-transpile-modules to bring in mixed modules and they worked just fine up until 12.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: exports is not defined error in Next.js
Looks related to this GitHub issue github.com/vercel/next.js/issues/38117, seems to have been introduced in the 12.2.0 release. Try downgrading ...
Read more >
How to fix ReferenceError: exports is not defined TypeScript
If you are getting the error for code that runs in the browser, try defining a global exports variable above the script tags...
Read more >
referenceerror: module is not defined in es module scope this ...
ReferenceError : exports is not defined in ES module scope This file is being treated as an ES module because it has a...
Read more >
ReferenceError: exports is not defined in TypeScript | bobbyhadz
To solve the "Uncaught ReferenceError: exports is not defined", add a script tag that defines an exports variable, e.g. <script>var exports = {};</script>...
Read more >
Uncaught ReferenceError: exports is not defined : r/typescript
Uncaught ReferenceError: exports is not defined · use module: "es6" in the tsconfig, so that the generated modules code runs natively in browsers....
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