question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Yarn PnP SDK shows several "@yarnpkg/pnpify" errors

See original GitHub issue

Summary

I use the Yarn PnP version of the “SDK” (.yarn/sdks/prettier/index.js) and am getting several of these errors when loading Prettier in VSCode:

Your application tried to access @yarnpkg/pnpify, but it isn’t declared in your dependencies; this makes the require call ambiguous and unsound.

Steps To Reproduce:

  1. Install Yarn PnP SDKs: dlx @yarnpkg/pnpify --sdk vscode
  2. Use this in settings.json: "prettier.prettierPath": ".yarn/sdks/prettier/index.js"
  3. Load VSCode

Expected result

Everything starts cleanly.

Actual result

The Output panel contains this:

["INFO" - 1:15:31 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 1:15:31 PM] Extension Version: 6.2.0.
["ERROR" - 1:15:31 PM] Error loading node module '/Users/borekb/prettier-demo/.yarn/sdks/prettier/index.js'
["ERROR" - 1:15:31 PM] Your application tried to access @yarnpkg/pnpify, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @yarnpkg/pnpify (via "@yarnpkg/pnpify")
Required by: /Users/borekb/prettier-demo/

Require stack:
- /Users/borekb/prettier-demo/.yarn/sdks/prettier/index.js
- /Users/borekb/.vscode/extensions/esbenp.prettier-vscode-6.2.0/dist/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
Error: Your application tried to access @yarnpkg/pnpify, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @yarnpkg/pnpify (via "@yarnpkg/pnpify")
Required by: /Users/borekb/prettier-demo/

Require stack:
- /Users/borekb/prettier-demo/.yarn/sdks/prettier/index.js
- /Users/borekb/.vscode/extensions/esbenp.prettier-vscode-6.2.0/dist/extension.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
    at internalTools_makeError (/Users/borekb/prettier-demo/.pnp.js:9920:34)
    at resolveToUnqualified (/Users/borekb/prettier-demo/.pnp.js:10879:23)
    at resolveRequest (/Users/borekb/prettier-demo/.pnp.js:10977:29)
    at Object.resolveRequest (/Users/borekb/prettier-demo/.pnp.js:11055:26)
    at Function.external_module_.Module._resolveFilename (/Users/borekb/prettier-demo/.pnp.js:10153:34)
    at Function.v.resolve (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:3:12349)
    at Object.<anonymous> (/Users/borekb/prettier-demo/.yarn/sdks/prettier/index.js:18:36)
    at Module.u._compile (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:3:12841)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1039:32)
    at Module._load (internal/modules/cjs/loader.js:932:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at Function.s._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:106:27167)
    at Function._._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:106:23919)
    at Function.W._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:96:4637)
    at Module.require (internal/modules/cjs/loader.js:1079:19)
    at Module.patchedRequire [as require] (/Users/borekb/.vscode/extensions/ryu1kn.partial-diff-1.4.1/node_modules/diagnostic-channel/dist/src/patchRequire.js:14:46)
    at v (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:3:12287)
    at t.ModuleResolver.loadNodeModule (/Users/borekb/.vscode/extensions/esbenp.prettier-vscode-6.2.0/src/ModuleResolver.ts:308:9)
    at t.ModuleResolver.<anonymous> (/Users/borekb/.vscode/extensions/esbenp.prettier-vscode-6.2.0/src/ModuleResolver.ts:188:11)
    at Generator.next (<anonymous>)
    at s (/Users/borekb/.vscode/extensions/esbenp.prettier-vscode-6.2.0/dist/extension.js:1:2695)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Formatting seems to work but the Output panel is full of these errors.

Additional information

VS Code Version: 1.54.2

Prettier Extension Version: 6.2.0

OS and version: macOS Big Sur (Darwin x64 20.3.0)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
merceyzcommented, Mar 16, 2021

This is expected, the sdk uses @yarnpkg/pnpify to allow prettier to scan node_modules for plugins, you need to add @yarnpkg/pnpify to your dependencies or remove that part of the sdk if you don’t need it

1reaction
borekbcommented, Mar 17, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Codes | Yarn - Package Manager
A list of Yarn's error codes with detailed explanations.
Read more >
Is `pnpify --sdk vscode` needed if you aren't using PnP with ...
Run yarn dlx @yarnpkg/pnpify --sdk vscode to add TypeScript support (cf Editor SDKs for more details); Commit the changes if you want to...
Read more >
Maël on Twitter: "@code_punkt @TypeS @yarn @yarnpkg ...
After v2 berry is installed globally, running "yarn pnpify --sdk" results in: ... However, the error that some package doesn't seem to be...
Read more >
Getting Started with Yarn 3 and TypeScript - In Plain English
Migration; Node 10 is now unsupported; @yarnpkg/sdks ... Before you could simply yarn pnpify --sdk vscode (I think that was the old ...
Read more >
Compatibililty with Yarn PnP (Plug and Play) feature - YouTrack
WEB-42177 Yarn PnP: ESLint doesn't show errors in default create-react-app ... Probably, some kind of support could be added with @yarnpkg/pnpify , but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found