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.

ESM module in Zod 2 beta causing runtime error

See original GitHub issue

With Zod 2.0.0-beta.20:

Screenshot

With Zod 1.11, no error.

Only seems to happen when using the object type

// no crash
z.string();
z.date();
// crashes
z.object({});
z.object({
  id: z.string(),
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
colinhackscommented, Nov 20, 2020

Gonna re-open because the root problem here isn’t solved 😦

3reactions
colinhackscommented, Nov 9, 2020

I removed the ESM module in zod@2.0.0-beta.21. If you upgrade your builds should work again.

I’ve also reproduced this issue. Now that I’m aware of this I’ll be able to guarantee ESM compatibility before trying to ship an ESM module again. It’s not trivial to fix so it’ll take some time. There are certain internal circular imports inside Zod’s source code that work fine with CommonJS modules but not with ESM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESM in .mjs files cause a dev mode runtime error · Issue #17806
Importing a project ESM .mjs file (the Node.js standard file extension for ESM) in a page file causes a runtime error, but only...
Read more >
require() of ES modules is not supported when importing node ...
js file has nothing but the import of node-fetch and it gives me an error message. What am I doing wrong? Running Ubuntu...
Read more >
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 >
Announcing TypeScript 4.7 RC - Microsoft Developer Blogs
In our beta release, we announced a stable target for our Node ESM support ... TypeScript 4.7 adds this functionality with two new...
Read more >
Colin McDonnell on Twitter: "Zod 3.0 has landed!! ❤️ It only ...
Zod 3.0 has landed!! ❤️ It only took a measly 8 months, 44 prereleases, and 446 commits! ☕️ ESM modules Deno...
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