1 year ago

#385104

test-img

Clarice Bouwer

Visual Studio Code Prettier extension intermittently throws an error on formatting

I need to restart Visual Studio Code several times a day because the Prettier formatter extension (esbenp.prettier-vscode) throws errors. It is as if the extension gets confused after numerous successful formats. Once the editor has been re-opened, the formatting works again, as expected. Any ideas what could be causing this?

I see the below in the output window:

["DEBUG" - 6:17:02 AM] Using bundled version of prettier.
["DEBUG" - 6:17:04 AM] Using bundled version of prettier.
["INFO" - 6:17:08 AM] Formatting file:///Users/soemthing/src/components/Unicorn/index.stories.mdx
["INFO" - 6:17:08 AM] Using config file at '/Users/something/.prettierrc'
["INFO" - 6:17:08 AM] Attempted to determine module path from package.json
["ERROR" - 6:17:08 AM] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
["ERROR" - 6:17:08 AM] Cannot read properties of undefined (reading 'uid')
TypeError: Cannot read properties of undefined (reading 'uid')
    at Object.code [as statSync] (/Users/me/.vscode/extensions/hoffs.vscode-versionlens-0.25.7/node_modules/npm/node_modules/graceful-fs/polyfills.js:309:17)
    at process (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/node_modules/resolve/lib/sync.js:23:21)
    at A (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/node_modules/resolve/lib/sync.js:140:13)
    at /Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/node_modules/resolve/lib/sync.js:108:16
    at Function.nodeModulesResDir [as sync] (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/node_modules/resolve/lib/sync.js:111:25)
    at t.ModuleResolver.Error [as findPkg] (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/src/ModuleResolver.ts:369:11)
    at t.ModuleResolver.logError [as getPrettierInstance] (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/src/ModuleResolver.ts:106:43)
    at t.default.format (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/src/PrettierEditService.ts:392:27)
    at t.PrettierEditProvider.provideEdits (/Users/me/.vscode/extensions/esbenp.prettier-vscode-9.5.0/src/PrettierEditService.ts:322:22)
    at B.provideDocumentFormattingEdits (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:102917)
["ERROR" - 6:17:08 AM] Prettier could not be loaded. See previous logs for more information.

Please let me know what information I should supply to elaborate with.

visual-studio-code

prettier

prettier-vscode

0 Answers

Your Answer

Accepted video resources