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.

yarn 2 berry: tsdx tried to access babel-jest, but it isn't declared in its dependencies;

See original GitHub issue

Current Behavior

when using v0.13.2 with yarn 2 berry, I get the following error when running tsdx test

Error: tsdx tried to access babel-jest, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

see also: https://github.com/jaredpalmer/tsdx/blob/3c65bdf90860c45a619b8a23720e41f8e251a4ef/src/createJestConfig.ts#L12

Expected behavior

all modules that are references using require or require.resolve have to be part of the dependencies of the package.

Suggested solution(s)

add babel-jest to the direct dependencies

Additional context

Your environment

Software Version(s)
TSDX 0.13.2
TypeScript 3.8.3
Browser n.a
npm/Yarn yarn 2 berry
Node 12.16.1
Operating System win

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
cspotcodecommented, Nov 10, 2020

In case this is helpful:

I think module.createRequire() is the correct approach when trying to load dependencies that you must assume are declared by a different package.json and not your own.

https://nodejs.org/api/module.html#module_module_createrequire_filename

1reaction
sgratzlcommented, Apr 21, 2020

so far I was able to manage it to get it work together with yarn 2 in my monorepo: https://github.com/upsetjs/upsetjs. It required some customization (like the rollup-plugin-pnp-resolve for rollup: https://github.com/upsetjs/upsetjs/blob/master/packages/model/tsdx.config.js) but doable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration | Yarn - Package Manager
A step-by-step and in-depth migration guide from Yarn 1 (Classic) to Yarn 2 (Berry).
Read more >
A guide through The Wild Wild West of setting up a mono repo ...
In this part, I will explain step by step how to setup Lerna, Yarn Workspaces and Typescript in a mono repo. In the...
Read more >
Problems with Intellisense with Yarn (berry) 2 PnP and ...
Questions in bold. Webstorm (tried 2020.2.2 and 2020.2.3RC) on Windows 10 x64 Webstorm should support Yarn 2 and PnP since 2019.3+ Is it......
Read more >
Introducing Yarn 2 ! - DEV Community ‍ ‍
If you just want to start right now with Yarn 2, check out the Getting ... to access // a package that is...
Read more >
Getting Started - Jest
Note: Jest documentation uses yarn commands, but npm will also work. You can compare yarn and npm commands in the yarn docs, here....
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