0

In the node_modules folder there is a prettier install (package.json says "version": "1.19.1",) that is overriding the .prettierrc in my project root.

When I delete that dir, formatting returns to normal.

But this is only temporary as npm i puts it back. Something has it as a dependency, even tho searching for "prettier" or 1.19.1 only returns the package-lock.json.

I have other projects that work correctly without a node_modules installation of prettier, but this github template had it.

How can I clear this up? Ideally, I want to only use the project level .prettierrc.

monsto
  • 1,178
  • 1
  • 13
  • 26

1 Answers1

0

You can find out which package is the culprit by searching in your package-lock.json. Each package in there has a requires field which lists its dependencies. That way you can traverse the chain to find out which dependency is causing the install.

Once you found the package, you have several options to force a specific dependency. In your case, you would force the latest version of prettier-plugin-svelte to be installed. In your case it's probably best to use npm shrinkwrap. You first add the latest version of prettier-plugin-svelte to your package.json, then do npm i, then make sure that only the latest prettier-plugin-svelte appears in your node_modules, then run npm shrinkwrap. More info here: https://nodejs.org/en/blog/npm/managing-node-js-dependencies-with-shrinkwrap/

More info and alternatives on forcing versions for various tools (npm/yarn) can be found in this StackOverflow answer: How do I override nested NPM dependency versions?

dummdidumm
  • 4,828
  • 15
  • 26