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
- Create an empty package.json (just
{}).
- Run
yarn policies set-version berry, it will install Yarn 2.0.0-rc.22
- Run
yarn install
- Create api-client.js file with the following content
require('pnpapi');
console.log('OK');
- Running
node --require ./.pnp.js api-client.js outputs OK
- Move
api-client.js outside of Yarn workspace with mv api-client.js ..
- 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
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.jsis 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
{}).yarn policies set-version berry, it will install Yarn 2.0.0-rc.22yarn installnode --require ./.pnp.js api-client.jsoutputsOKapi-client.jsoutside of Yarn workspace withmv api-client.js ..node --require ./.pnp.js ../api-client.jsfails withError: Cannot find module 'pnpapi'Environment if relevant (please complete the following information):