Closed Namukk closed 3 years ago
I’ve the same problem. Happens only with the latest version 6.2.0, works with 5.9.2
I too see a similar problem (MacOS Mojave), no formatting with V6.2.0 but does work with 5.9.2.
Same problem with formatting settings.json (VS Code settings), other formats including json ones work fine.
I am not able to reproduce this issue. Could you provide a copy of your VS Code settings as a JSON document?
@nikita-beletskiy This is a separate issue. I opened #1845 to track.
Here is my settings file (I've removed the long list of spellcheck exceptions and redacted my username)
{
"editor.fontFamily": "iosevka,Menlo, Monaco, 'Courier New', monospace",
"workbench.colorTheme": "Quiet Light",
"editor.fontSize": 14,
"markdownlint.config": {
"MD013": false,
"MD026": { "punctuation": ".,;:!" },
"MD030": { "ol_single": 2, "ol_multi": 2 },
"MD041": false
},
"git.autofetch": true,
"editor.minimap.enabled": false,
"breadcrumbs.enabled": false,
"markdown-preview-enhanced-with-litvis.liveUpdate": false,
"[elm]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[markdown]": {
// Controls if the editor should automatically close brackets after opening them
"editor.autoClosingBrackets": "never"
},
"workbench.startupEditor": "newUntitledFile",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"diffEditor.ignoreTrimWhitespace": false,
"git.confirmSync": false,
"workbench.editor.wrapTabs": true,
"prettier.resolveGlobalModules": true,
"cSpell.customFolderDictionaries": [
],
"cSpell.enableFiletypes": [
"elm"
],
"prettier.prettierPath": "/Users/XXXX/.nvm/versions/node/v12.16.2/bin",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
{
"prettier.arrowParens": "avoid",
"prettier.jsxSingleQuote": true,
"prettier.singleQuote": true,
"prettier.trailingComma": "none",
"editor.formatOnSave": true,
"editor.accessibilityPageSize": 1,
"editor.accessibilitySupport": "off",
"editor.tabSize": 2,
"editor.hover.delay": 500,
"editor.fontFamily": "Consolas, monospace",
"editor.smoothScrolling": true,
"editor.tabCompletion": "on",
"editor.cursorStyle": "line-thin",
"editor.fontSize": 15,
"editor.minimap.scale": 3,
"editor.minimap.showSlider": "always",
"editor.acceptSuggestionOnCommitCharacter": false,
"editor.wordWrap": "bounded",
"workbench.commandPalette.history": 0,
"workbench.enableExperiments": false,
"workbench.startupEditor": "none",
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Material Theme Ocean",
"workbench.editor.limit.perEditorGroup": true,
"workbench.editor.mouseBackForwardToNavigate": false,
"workbench.editor.restoreViewState": false,
"workbench.editor.tabSizing": "shrink",
"window.zoomLevel": 0.2,
"window.autoDetectHighContrast": false,
"update.enableWindowsBackgroundUpdates": false,
"update.mode": "start",
"update.showReleaseNotes": false,
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "comment",
"settings": { "foreground": "#659955", "fontStyle": "italic" }
},
{
"scope": "punctuation.definition.comment.js",
"settings": { "foreground": "#659955" }
}
]
},
"emmet.includeLanguages": {
"javascript": "javascriptreact"
},
"kite.showWelcomeNotificationOnStartup": false,
"kite.loggingLevel": "error",
"kite.codefinder.enableLineDecoration": false,
"git.enableSmartCommit": true,
"liveServer.settings.donotShowInfoMsg": true,
"liveServer.settings.CustomBrowser": "chrome:PrivateMode",
"liveSassCompile.settings.formats": [
{
"format": "expanded",
"extensionName": ".css",
"savePath": "/dist/css"
}
],
"quokka.showOutputOnStart": false
}
@jwoLondon The value "/Users/XXXX/.nvm/versions/node/v12.16.2/bin"
is not a valid value for prettier.prettierPath
. It needs to be to the module path not the bin path.
See: https://github.com/prettier/prettier-vscode#prettierprettierpath
Thanks for that. Hopefully useful information though that having this incorrect path was not a problem prior to V6.2.0. It looks like setting the correct path means "prettier.resolveGlobalModules": true
is no longer necessary.
It looks like setting the correct path means "prettier.resolveGlobalModules": true is no longer necessary.
They do different things. If you don't have a path set, resolveGlobalModules
will search your global modules for prettier
. If you set a prettierPath
that will be used no matter what, no other searches will happen.
I'm not sure why that worked in previous versions. I almost wonder if it failed silently and was falling back to the built-in version of prettier in the extension. v6 is a bit more aggressive on failing on error states.
{
"editor.formatOnSave": true,
"workbench.colorTheme": "Material Theme Darker",
"workbench.iconTheme": "material-icon-theme",
"editor.fontSize": 13,
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"terminal.integrated.automationShell.osx": "",
"terminal.integrated.shell.osx": "",
"terminal.integrated.fontFamily": "\"Meslo LG M for Powerline\"",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.enableDebugLogs": true,
}
I am still not able to reproduce this. Are any logs produced when you manually run "Format Document"?
Formatting on saving tsx works, but saving scss doesn't format anymore (since v6 update, works fine after rolling back to 5.9.2) and there's nothing new in Prettier output except ["INFO" - 18:21:08] Using bundled version of prettier.
.
Are any logs produced when you manually run "Format Document"?
vscode says that there are multiple formatters for scss and offers to choose one to continue, with a list of Prettier x2 (screenshot)
UPD: After I selected the first one, it seemingly fixed the issue. Any idea why there could be two? It added this to my settings.json:
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Looks like it worked even without it in v5 for some reason.
Formatting works only if forced, and no output logs neither when just save, nor when try to format manually, just getting a message in a status bar that it cannot format.
@ntotten No, it doesn't produce
Try version 6.3.1. I think this should be fixed. Let me know.
@ntotten Thanks it is working now 👍
Just to note that unfortunately this is still a problem with my setup.
To summarise:
MacOS Mojave, node modules installed via nvm, prettier 2.2.1 installed as a global module
Prettier path is set to /Users/XXXX/.nvm/versions/node/v12.16.2/lib/node_modules/prettier
(although even when not set at all, or set to an incorrect folder, this has no effect on any of the observations below).
In 6.3.1, with 'resolve global modules' set to true (which I need for another plugin markdown-preview-enhanced-with-litvis), prettier is not invoked. No error message in output window, nor are the prettier options shown.
If resolve global modules
is set to false, prettier formatting does work for .js files, but not for code blocks within markdown. No error message or prettier options shown in output.
All appears to work as expected in V5.9.2, but problems as above in 6.2.0, 6.3.0 or 6.3.1
It would appear therefore that something has changed after 5.9.2 that prevents prettier-plugin from picking up global modules installed via nvm.
@jwoLondon A lot of the time these issues are caused by various version and config settings that are difficult to duplicate. Please provide a sample Github repo that I can use to duplicate this issue. For more details see this guide.
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.
Summary
Even I set format on save and prettier as a default formatter, when I save my code it isn't fixed. It shows error 'Extension 'Prettier - Code formatter' cannot format ....'
Github Repository to Reproduce Issue
https://github.com/Namukk/nomflix
Steps To Reproduce:
Expected result
It should fix my code. Even I downloaded extensions and vscode again It shows same error.
Actual result
It doesn't fix my code with error
Extension 'Prettier - Code formatter' cannot format ....
Additional information
VS Code Version: 1.54.2
Prettier Extension Version: 6.2.0
OS and version: macOs Big Sur 11.2.3
Prettier Log Output