Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions does not work with YARN PnP #1502

Closed
abdes opened this issue Aug 5, 2020 · 4 comments
Closed

Extensions does not work with YARN PnP #1502

abdes opened this issue Aug 5, 2020 · 4 comments
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@abdes
Copy link

abdes commented Aug 5, 2020

Summary

Yarn PnP does not have a node_modules in the workspace folder. The extension attempts to do its own resolution to load prettier and its plugins from the workspace in an incompatible way with YARN PnP.

Doing a npm install in the same project to just create a node_modules and populate it fixes the issue for prettier extension. But that is not the point, right :-). Yarn PnP does not need a node_modules.

Steps To Reproduce:

  1. Any new project with yarn berry (yarn v2) for an out of the box PnP setup
  2. Add prettier and plugins to package.json
  3. Configure vscode to work with yarn berry: https://yarnpkg.com/advanced/editor-sdks#vscode
  4. start vscode => format any file with prettier extension

Expected result

No errors and file formatted properly.
Note that prettier from the command line in the same environment with PnP works perfectly fine.

Actual result

The result is:

["ERROR" - 8:35:50 PM] Cannot find module 'prettier' from 'e:\dev\projects\yarn-workspaces\yarn-dep-graph'
Error: Cannot find module 'prettier' from 'e:\dev\projects\yarn-workspaces\yarn-dep-graph'
	at Function.e.exports [as sync] (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:44268)
	at t.ModuleResolver.findPkg (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:30336)
	at t.ModuleResolver.findPkg [as findPkgMem] (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:33675)
	at t.ModuleResolver.requireLocalPkg (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:28684)
	at t.ModuleResolver.getPrettierInstance (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:27415)
	at t.LanguageResolver.getSupportLanguages (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:25522)
	at t.LanguageResolver.allEnabledLanguages (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:25231)
	at t.default.selectors (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:54753)
	at registerFormatter (c:\Users\USER\.vscode\extensions\esbenp.prettier-vscode-5.1.3\dist\extension.js:1:54055)
	at l.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:45:801)
	at e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:661:802
	at l.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:45:801)
	at t.ExtHostFileSystemEventService.$onFileEvent (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:663:41)
	at m._doInvokeHandler (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:801:683)
	at m._invokeHandler (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:801:375)
	at m._receiveRequest (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:800:14)
	at m._receiveOneMessage (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:798:832)
	at e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:797:34
	at l.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:45:801)
	at v.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:235:849)
	at e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:975:744
	at l.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:45:801)
	at v.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:235:849)
	at t.PersistentProtocol._receiveMessage (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:240:276)
	at e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:237:357
	at l.fire (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:45:801)
	at p.acceptChunk (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:233:393)
	at e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:232:753
	at Socket.t (e:\dev\vscode\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:241:826)
	at Socket.emit (events.js:203:13)
	at addChunk (_stream_readable.js:295:12)
	at readableAddChunk (_stream_readable.js:276:11)
	at Socket.Readable.push (_stream_readable.js:210:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)
["INFO" - 8:35:50 PM] Enabling prettier for languages

Additional information

Feel free to attach a screenshot.

VS Code Version: 1.47.3

Prettier Extension Version: v5.1.3

OS and version: Windows 10

@ntotten ntotten added the uncomfirmed Possible bugs that haven't been confirmed label Aug 6, 2020
@ntotten ntotten removed the uncomfirmed Possible bugs that haven't been confirmed label Sep 8, 2020
@ntotten
Copy link
Member

ntotten commented Sep 8, 2020

This seems to be a bug on Prettier itself. Prettier alone works as expected in both vscode and through the CLI when I use PnP as documented here: https://yarnpkg.com/advanced/editor-sdks#vscode. However, when I install a plugin prettier fails to resolve it in either the CLI or VS Code.

Please open a new bug with Prettier directly and reference this issue: https://github.com/prettier/prettier/issues

@ntotten ntotten closed this as completed Sep 8, 2020
@jackgeek
Copy link

For anyone looking for a solution. I found this which helped:
#1066 (comment)

@jamescook10
Copy link

Yarn pnp now supports this plugin. As @ntotten suggests above visit https://yarnpkg.com/advanced/editor-sdks#vscode for full details.

The line you want to run in your terminal inside your project dir is:

yarn dlx @yarnpkg/pnpify --sdk vscode

This does some magic to tell the prettier-vscode plugin where to find the local prettier module.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Feb 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

4 participants