Skip to content

Yarn berry doesn't recognize jest when it's a dependency of another package. #2784

@TarikGul

Description

@TarikGul
  • I'd be willing to implement a fix

Hey Yarn Berry Team,

Thanks again for all the work, absolutely loving what I have used so far, I think it's a wonderful step in the right direction! Keep up the amazing work.

Describe the bug

Now my issue is most likely a lack of understanding on my part but I cant seem to understand what Berry is doing which is causing this issue or how to resolve it.

I am migrating our repos from using classic Yarn to Berry, and we have an internal package that has our jest test library and eslint with all our configuration's that we use in all our repos. With classic it was pretty simple I would just yarn add @substrate/dev and the jest command would work right away.

But after migrating to Berry i get command not found: jest.

I wrote a very lightweight repo with a single dep below to demonstrate the issue I am having.

To Reproduce

Steps I took to create:

$ mkdir test-repo
$ cd test-repo
$ npm init -y
$ yarn set version berry
$ yarn add @substrate/dev

# <add script "test" to package.json as follows> "test": "jest --silent"
$ yarn run test
command not found: jest

Now if I delete the .yarn folder and .yarnrc.yml and rely on classic yarn, the script will recognize jest, and work.

The sample Repo.

Here's the package @substrate/dev includes both jest and eslint.

package.json

{
  "name": "test-yarn2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest --silent"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@substrate/dev": "^0.4.1"
  }
}

.yarnrc.yml

nodeLinker: node-modules

yarnPath: ".yarn/releases/yarn-berry.cjs"

I looked through the docs, and couldn't find a solution that fits my needs. Looking for some direction if possible. Thanks again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions