prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.04k stars 446 forks source link

Prettier Not Formatting Documents #3263

Closed EndCod3r closed 4 months ago

EndCod3r commented 4 months ago

Summary

I installed Prettier for VS Code and I'm getting an error in the bottom right.

Github Repository to Reproduce Issue

Installed the latest Prettier VS Code extension.

Steps To Reproduce:

  1. Open a HTML file in VS Code
  2. Prettier error in bottom right

Expected result

Prettier formatting files

Actual result

Prettier shows errors

VS Code Version:

Version: 1.85.1 (user setup) Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2 Date: 2023-12-13T09:49:37.021Z Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19045

Prettier Extension Version: Prettier: 10.1.0 OS and version: Windows 10 22H2

Prettier Log Output

["INFO" - 12:58:49 AM] Attempted to determine module path from c:\Users\endlo\Projects\GitHub\example
["ERROR" - 12:58:49 AM] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
["ERROR" - 12:58:49 AM] Cannot find module 'prettier' from 'c:\Users\endlo\Projects\example'
Error: Cannot find module 'prettier' from 'c:\Users\endlo\Projects\example'
    at e.exports [as sync] (c:\Users\endlo\.vscode\extensions\esbenp.prettier-vscode-10.1.0\dist\extension.js:1:40995)
    at t.ModuleResolver.findPkg (c:\Users\endlo\.vscode\extensions\esbenp.prettier-vscode-10.1.0\dist\extension.js:1:8287)
    at t.ModuleResolver.getPrettierInstance (c:\Users\endlo\.vscode\extensions\esbenp.prettier-vscode-10.1.0\dist\extension.js:1:4588)
    at t.default.handleActiveTextEditorChanged (c:\Users\endlo\.vscode\extensions\esbenp.prettier-vscode-10.1.0\dist\extension.js:1:10771)
    at f.handleActiveTextEditorChangedSync [as value] (c:\Users\endlo\.vscode\extensions\esbenp.prettier-vscode-10.1.0\dist\extension.js:1:10373)
    at n.y (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
    at n.z (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1972)
    at n.fire (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2188)
    at f.value (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:145:16612)
    at n.y (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
    at n.fire (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
    at i.acceptDocumentsAndEditorsDelta (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:143:12599)
    at i.$acceptDocumentsAndEditorsDelta (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:143:10970)
    at l.S (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:10829)
    at l.Q (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:10595)
    at l.M (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:9685)
    at l.L (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:8764)
    at f.value (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:7567)
    at n.y (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
    at n.fire (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
    at o.fire (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:103:14039)
    at f.value (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:7903)
    at n.y (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
    at n.fire (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
    at o.fire (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:103:14039)
    at MessagePortMain.<anonymous> (c:\Users\endlo\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:6183)
    at MessagePortMain.emit (node:events:513:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)
dominiccarrington commented 4 months ago

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

It looks like you have prettier defined in your package.json file. Have you run npm install (or equivalent for your package manager)

EndCod3r commented 4 months ago

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

It looks like you have prettier defined in your package.json file. Have you run npm install (or equivalent for your package manager)

This issue still happens in an folder with just an HTML file in it and I don't even have npm installed anyways.

EndCod3r commented 4 months ago

I seemed to have fixed it somehow. I reinstalled VS Code and deleted everything left behind and installed Prettier and my other extensions but that didn't work, but when I went to work on a project it started working again.

github-actions[bot] commented 1 month ago

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.