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.

@babel/runtime dependency while consuming Zustand with Typescript

See original GitHub issue

When importing Zustand in a typescript (node CLI) project, I’m getting this error:

Error: Cannot find module '@babel/runtime/regenerator'
Require stack:
- /Users/me/projects/project/node_modules/zustand/index.cjs.js

There seem to be an index.js and an index.cjs.js, with Typescript importing the latter. The index.cjs.js requires @babel/runtime. My Node version is 12.x and my tsconfig looks like this:

{
    "compilerOptions": {
        "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
        "module": "commonjs",
        "target": "es2019",
        "strict": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true,
        "jsx": "react"
    }
}

I rather not change my tsconfig or Node version, unless there is a compelling reason. Is it correct that for my case I need to install @babel/runtime as a dependency? I would expect not to, since tsc should probably take care of everything?

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
dai-shicommented, Sep 29, 2020

It might be better if you could use the ESM build index.js. Not sure how to configure your env. Can anyone else help here?

0reactions
dai-shicommented, Jun 6, 2021

Oh, yes. That was one my huge motivation on #403.

Read more comments on GitHub >

github_iconTop Results From Across the Web

zustand - Bountysource
When importing Zustand in a typescript (node CLI) project, I'm getting this error: Error: Cannot find module '@babel/runtime/regenerator' Require stack: ...
Read more >
TS-runtime: Runtime Type Checks for TypeScript - Morioh
A package for generating runtime type checks from TypeScript type annotations ... While you know that the returned value will be a number,...
Read more >
[AskJS] What libraries do you use for your development?
It gets grey when you use a library for a UI component that might save time ... Lint Staged. TypeScript. Jest. JSDOM. Testing...
Read more >
How to fix - Module not found: Can't resolve '@babel/runtime ...
Make sure you got @babel/runtime installed into your regular dependencies and not the devDependencies (leave out the --dev or the -D flag ...
Read more >
What happened to Components being just a visual thing?
I really like when Components are actually just visual components. ... This makes the usage of dependency-consuming Component magical.
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