Skip to content

[Bug] PnP API cannot be consumed if file located outside workspace #693

Description

@segrey

Describe the bug

require('pnpapi') fails if it's run in a file located outside Yarn workspace.
For example, IntelliJ consumes PnP API in this way (intellij-yarn-pnp-deps-tree-loader.js is located in IDE installation folder) and after updating Yarn to 2.0.0-rc.22 it fails. This disables IntelliJ Yarn 2 integration unfortunately.

To Reproduce

  1. Create an empty package.json (just {}).
  2. Run yarn policies set-version berry, it will install Yarn 2.0.0-rc.22
  3. Run yarn install
  4. Create api-client.js file with the following content
require('pnpapi');
console.log('OK');
  1. Running node --require ./.pnp.js api-client.js outputs OK
  2. Move api-client.js outside of Yarn workspace with mv api-client.js ..
  3. Running node --require ./.pnp.js ../api-client.js fails with Error: Cannot find module 'pnpapi'

Environment if relevant (please complete the following information):

  • OS: Linux
  • Node version 12.11.1
  • Yarn version 2.0.0-rc22

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions