Cannot find module prettier-plugin-svelte
See original GitHub issueSummary
prettier-vscode cannot find prettier-plugin-svelte but prettier does.
Running format in vscode fails and the output pane for prettier shows:
Error: Cannot find module 'prettier-plugin-svelte' from '/'
Prettier module works fine and format js and svelte files correctly
Github Repository to Reproduce Issue
https://github.com/plrenaudin/last-boilerplate
Steps To Reproduce:
- open src/main.js
- change content and format the file
Expected result
File gets formatted and prettier console output doesn’t show an error
Actual result
Nothing changes and Error: Cannot find module 'prettier-plugin-svelte' from '/'
appear in the prettier console output
Additional information
VSCode setting:
"editor.defaultFormatter": "esbenp.prettier-vscode"
VS Code Version: 1.42.1
Prettier Extension Version: 3.20
OS and version: MacOS Catalina
Prettier Log Output
Error: Cannot find module 'prettier-plugin-svelte' from '/'
at Function.sync (/Users/plrenaudin/Projects/last-boilerplate/node_modules/prettier/index.js:15946:13)
at /Users/plrenaudin/Projects/last-boilerplate/node_modules/prettier/index.js:44141:29
at Array.map (<anonymous>)
at loadPlugins (/Users/plrenaudin/Projects/last-boilerplate/node_modules/prettier/index.js:44133:59)
at /Users/plrenaudin/Projects/last-boilerplate/node_modules/prettier/index.js:44205:16
at Object.format (/Users/plrenaudin/Projects/last-boilerplate/node_modules/prettier/index.js:44226:12)
at /Users/plrenaudin/.vscode/extensions/esbenp.prettier-vscode-3.20.0/dist/extension.js:1:350954
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:13 (1 by maintainers)
Top Results From Across the Web
prettier-plugin-svelte - npm
Svelte plugin for prettier. Latest version: 2.9.0, last published: 14 days ago. Start using prettier-plugin-svelte in your project by ...
Read more >Cannot find module 'prettier' error | bobbyhadz
To solve the error "Cannot find module 'prettier'", make sure to install the prettier package by opening your terminal in your project's root...
Read more >Prettier plugin does not format *.svelte files, even ... - YouTrack
I've double-checked that the request to format svelte file is sent correctly but Prettier service responds that the file is unsupported. You'll see...
Read more >prettier-plugin-svelte | Yarn - Package Manager
Format your Svelte components using Prettier. Features. Format your HTML, CSS, and JavaScript using prettier; Format Svelte syntax, e.g. each loops, if ...
Read more >Plugins - Prettier
When plugins cannot be found automatically, you can load them with: ... so you can provide a module/package name, a path, or anything...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue is you have an invalid value set in “plugins”. It’s not a list of plugins, it’s a file path to the plugin. Set the value to ./directory/plugin and it will work.
Also, if you have the plugin and prettier installed in your local project this setting is not needed anyway. All installed plugins are automatically loaded.
This solution solved my problem, just delete
"plugins": ["prettier-plugin-svelte"]
on .prettierrc and prettier work well on .js file or .svelte file, thanks.