Skip to content

utils.ensurePackageInstalled is not compatible with yarn PnP #899

@pietrovismara

Description

@pietrovismara

Describe the bug

Trying to run vitest in a package of a yarn monorepo will cause the following error:

 MISSING DEP  Can not find dependency 'vite'

✖ Do you want to install vite? … no

I already have vite installed and apparently the issue is caused by this line:

if (isPackageExists(dependency))

The local-pkg is not compatible with yarn PnP, as confirmed by this issue.

As far as I understand it, it should be enough to call isPackageExists with a second options parameters like this:

isPackageExists(dependency, { paths: [ process.cwd() ] })

I already tested this solution locally with a fork of local-pkg and it works.

Reproduction

The issue is already confirmed.

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: x64 Intel [redacted]
    Memory: 2.72 GB / 7.63 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.2 - /usr/bin/node
    Yarn: 3.1.1 - /usr/bin/yarn
    npm: 8.1.2 - /usr/bin/npm

Used Package Manager

yarn

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions