Support Yarn PnP module resolution
See original GitHub issueThe Files.resolve
function exported by vscode-languageserver
fails to resolve node modules in a Yarn PnP environment. This causes for example vscode-eslint
to stop working when using PnP (see microsoft/vscode-eslint#601).
In order to support Yarn PnP, the project’s local .pnp.js
file needs to be required.
Quick pseudocode for how this should work:
if (is yarn pnp) {
require(cwd + '/.pnp.js')
}
// ...rest
I think this has to be done at some point during the app
script in Files#resolve
:
Edit: Or better yet, add --require /path/to/.pnp.js
to the node CLI arguments here:
That would be the recommended approach by the Yarn docs.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Plug'n'Play | Yarn - Package Manager
The Node resolution doesn't have to iterate over the filesystem hierarchy nearly as much as before (and soon won't have to do it...
Read more >Module resolution breaking for Yarn PNP in TS 4.8 #50547
Our repo is using Yarn Berry workspaces with PNP, and after upgrading to 4.8, we are seeing a lot of errors resolving modules...
Read more >Compatibililty with Yarn PnP (Plug and Play) feature - YouTrack
Hi, I just wanted to know if there are some plans to support the new feature of Yarn (the Pnp or Plug and...
Read more >wheatstalk/cdk-lambda-pnp - npm
Deploy your AWS Lambdas from a Yarn PnP workspace using the CDK. ... module resolution; Supports hard-to-bundle packages if yarn PnP ...
Read more >VS Code and Yarn PnP - typescript - Stack Overflow
Cannot find module 'react' or its corresponding type declarations. It builds and runs via webpack. This appears to be a VS Code/sdk artifact....
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 FreeTop 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
Top GitHub Comments
Discussing this in the ESLint repository is the best location. It was a mistake to add the resolve feature to the server in the first place and I actually will not improve this further. Loading stuff from the workspace folder should be best done by the extension that wants to load these files.
So I close the issue in favour of the having a solution in ESLint.
I am using yarn v2 (berry) for a monorepo, taking advantage of pnp and workspaces but
vscode-eslint
doesn’t work because of this issue.pnp comes by default with yarn v2 (berry). Regarding v1, I’m not sure how to check if pnp is enabled or not…
I would like to start a PR myself but there are some unknowns: