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.

extension fails with yarn2

See original GitHub issue

Summary

I use yarn2 to install dependencies

Github Repository to Reproduce Issue

repo is private

Steps To Reproduce:

  1. setup yarn2
  2. setup all dependencies for the project yarn install
  3. open any file of the project in vs code with prettier extension

Expected result

usual behaviour as it was on prior version of yarn

Actual result

Error: Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run npm install Attempted to load prettier from package.json

Sourse: Prettier - Code Formatter [extension]

image

Additional information

VS Code Version: 1.41.1

Prettier Extension Version: 3.18.0

OS and version: MacOS 10.15.2 (19C57)

Prettier Log Output

["ERROR" - 11:02:41 PM] Failed to load prettier from ''**Censored**
Cannot find module 'prettier' from '/Users/**Censored**/projects/**Censored**/**Censored**/package.json'
Error: Cannot find module 'prettier' from '/Users/**Censored**/projects/**Censored**/**Censored**/package.json'
	at Function.e.exports [as sync] (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:319843)
	at t.ModuleResolver.findPkg (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:246852)
	at t.ModuleResolver.findPkg [as findPkgMem] (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:247210)
	at t.ModuleResolver.requireLocalPkg (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:245330)
	at t.ModuleResolver.getPrettierInstance (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:243969)
	at t.LanguageResolver.getSupportLanguages (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:242420)
	at t.LanguageResolver.allEnabledLanguages (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:242028)
	at t.StatusBarService.toggleStatusBarItem (/Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:85577)
	at /Users/**Censored**/.vscode/extensions/esbenp.prettier-vscode-3.18.0/dist/extension.js:1:85250
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:893)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:641:245
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:893)
	at f.$acceptDocumentsAndEditorsDelta (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:561:804)
	at p._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:663:275)
	at p._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:662:971)
	at p._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:661:639)
	at p._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:660:468)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:658:691
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:893)
	at _.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:189:274)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:820:285
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:893)
	at _.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:189:274)
	at t.PersistentProtocol._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:193:629)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:190:824
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:893)
	at p.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:186:737)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:186:89
	at Socket.t (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:195:68)
	at Socket.emit (events.js:200:13)
	at addChunk (_stream_readable.js:294:12)
	at readableAddChunk (_stream_readable.js:275:11)
	at Socket.Readable.push (_stream_readable.js:210:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:15
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
crubiercommented, Feb 29, 2020

@ntotten the problem here is that even when setting the vscode setting ;

"prettier.prettierPath": ".vscode/pnpify/prettier/index.js"`

(As done automatically by following https://yarnpkg.com/advanced/editor-sdks )

It looks like the plugins still tries to load the version from package.json first instead of the explicitly configured path.

["INFO" - 7:15:59 PM] Formatting /Users/xxxx/Code/sterblue2/packages/algorithms/random/src/index.ts
["INFO" - 7:15:59 PM] Using ignore file (if present) at /Users/xxx/Code/sterblue2/.prettierignore
["ERROR" - 7:15:59 PM] Failed to load local module prettier.
["ERROR" - 7:15:59 PM] Cannot find module 'prettier' from '/Users/xxxx/Code/sterblue2/package.json'
Error: Cannot find module 'prettier' from '/Users/xxx/Code/sterblue2/package.json'
	at Function.e.exports [as sync] (/Users/xxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:320528)
	at t.ModuleResolver.findPkg (/Users/xxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:247279)
	at t.ModuleResolver.findPkg (/Users/xxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:247381)
	at t.ModuleResolver.findPkg [as findPkgMem] (/Users/xxxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:247637)
	at t.ModuleResolver.requireLocalPkg (/Users/xxxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:245697)
	at t.ModuleResolver.getPrettierInstance (/Users/xxxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:244301)
	at t.default.<anonymous> (/Users/xxxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:348961)
	at Generator.next (<anonymous>)
	at s (/Users/xxxxx/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:345019)
["INFO" - 7:15:59 PM] Using bundled version of prettier.
["INFO" - 7:15:59 PM] File Info:
{
  "ignored": false,
  "inferredParser": "typescript"
}
["INFO" - 7:15:59 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 7:15:59 PM] Prettier Options:
{
  "filepath": "/Users/xxxx/xxx/index.ts",
  "parser": "typescript",
  "useTabs": false,
  "tabWidth": 2,
  "printWidth": 80,
  "semi": true,
  "singleQuote": false,
  "jsxSingleQuote": false,
  "trailingComma": "none",
  "bracketSpacing": true,
  "jsxBracketSameLine": false,
  "arrowParens": "avoid",
  "htmlWhitespaceSensitivity": "css",
  "endOfLine": "lf"
}
["INFO" - 7:15:59 PM] Formatting completed in 40.413031ms.
2reactions
ntottencommented, Jan 27, 2020

For now, you will have to set the prettier path. This is probably going to be a fairly large investment to fix due to how yarn2 has changed dependency resolution. I will try to look into it soon, but if somebody has expertise with yarn2 a PR would be welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Codes | Yarn - Package Manager
This usually occurs in only two cases: either the package never has been built before, or its previous build failed (returned a non-zero...
Read more >
How to configure VSCode to run Yarn 2 (with PnP) powered ...
I had this problem last night while migrating to Yarn v2 and using PnP. Make sure that after running yarn dlx @yarnpkg/sdks vscode...
Read more >
242936 – editors/vscode: Fails to build: yarn attempts to fetch ...
Hi, On an 12.1 AMD64 box, I am trying to build editors/vscode from ports with all default config options on.
Read more >
Yarn Install fails with ESOCKETTIMEDOUT for few npm ...
error An unexpected error occurred: "https://registry.yarnpkg.com/@fluentui ... We have determined that this issue belongs to Geek Learning's Yarn extension ...
Read more >
Yarn build fails in deployment - [@roots/bud-preset-wordpress ...
Running into an issue running yarn build when deploying a new Sage 10 site ... made-beanies/node_modules/@roots/bud-preset-wordpress/lib/extension.js:10:57) ...
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