[Bug] Yarn 2.4.0 reading parent .pnp.js for pnpApi when enableGlobalCache is false
See original GitHub issue- I’d be willing to implement a fix
Describe the bug
I upgraded from Yarn 2.3.3 to 2.4.0 and am unable to run a yarn script in a child directory. I have the following folder structure:
package.json
yarn.lock
.yarn/releases/yarn-2.4.0.cjs
.yarnrc.yml
/lib/package.json
/lib/yarn.lock
As part of my root package I have pnpify installed so I can use eslint across all sub projects.
When you install the root, then enabled pnpify, then install lib, and then run any yarn command from the lib scripts you get the following error:
Internal Error: Unable to locate pnpapi, the module '/Projects/demo/lib/.pnp.js' is controlled by multiple pnpapi instances.
This is usually caused by using the global cache (enableGlobalCache: true)
Controlled by:
/Projects/demo/lib/.pnp.js
/Projects/demo/.pnp.js
This is usually caused by using the global cache (enableGlobalCache: true)
Controlled by:
/Projects/demo/lib/.pnp.js
/Projects/demo/.pnp.js
at Object.findApiPathFor (/Projects/demo/lib/.pnp.js:29343:13)
at Function.external_module_.Module._resolveFilename (/Projects/demo/lib/.pnp.js:28315:182)
at Function.external_module_.Module._load (/Projects/demo/lib/.pnp.js:28204:48)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at S (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:418340)
at Module.k (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:418445)
at S.findPackageLocation (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:265281)
at /Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:425060
at Function.openPromise (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:489248)
To Reproduce
I’ve created a demo repo to reproduce the issue here. These are the steps to setup the demo and what to expect:
Setup Steps
- Run
yarn install
in the root directory - Run
yarn pnpify --sdk vscode
to install the sdks - Run
yarn install
in the lib directory - Run
yarn dev
in the lib directory
You should receive the following error message when you run yarn dev
:
Internal Error: Unable to locate pnpapi, the module '/Projects/demo/lib/.pnp.js' is controlled by multiple pnpapi instances.
This is usually caused by using the global cache (enableGlobalCache: true)
Controlled by:
/Projects/demo/lib/.pnp.js
/Projects/demo/.pnp.js
This is usually caused by using the global cache (enableGlobalCache: true)
Controlled by:
/Projects/demo/lib/.pnp.js
/Projects/demo/.pnp.js
at Object.findApiPathFor (/Projects/demo/lib/.pnp.js:29343:13)
at Function.external_module_.Module._resolveFilename (/Projects/demo/lib/.pnp.js:28315:182)
at Function.external_module_.Module._load (/Projects/demo/lib/.pnp.js:28204:48)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at S (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:418340)
at Module.k (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:418445)
at S.findPackageLocation (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:265281)
at /Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:425060
at Function.openPromise (/Projects/demo/.yarn/releases/yarn-2.4.0.cjs:2:489248)
Screenshots
N/A
Environment if relevant (please complete the following information):
- OS: Mac OS 11.1
- Node version 12.19.0
- Yarn version 2.4.0
Additional context
None
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error: Unable to locate pnpapi ... is controlled by multiple ...
Run a project with Yarn 2 pnp; Have some incorrect globalCache settings? ... listed in external dependencies and in Settings > Javascript >...
Read more >Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >Repository - GitLab
Yarn supports zero-installs, which means that as long as you store your cache and your .pnp.js file inside your repository, everything will ...
Read more >Taxonomy - PnP/PnPjs
The side affect of this is that the parent is no longer chainable, meaning you need to load a new term instance to...
Read more >Plug'n'Play | Yarn - JavaScript 软件包管理器
If the answer to any of these questions is yes, make sure to visit the PnP API page after reading the introduction! Unveiled...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems to be a bug here on our end, you can work around it by getting more specific with the pattern
Make sure to run an install after modifying
.yarnrc.yml
Hi, I am facing this error please help me, it’s a bit different and I can’t fix it by myself… I just updated my yarn version to version 2.4.3 from version 1.x
and I got this error