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.

Cannot find module prettier-plugin-svelte

See original GitHub issue

Summary

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:

  1. open src/main.js
  2. 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ntottencommented, May 11, 2020

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.

3reactions
oniharnantyo123commented, Aug 3, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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