2

I have Prettier extension installed in my VS Code. Up until the last update everything worked fine, and now I am prompted with this question:

The Prettier extension will use 'node_modules/prettier/index.js' for validation, which is installed locally in folder 'my_project_folder'. Do you allow the execution of the Prettier version including all plugins and configuration files it will load on your behalf?

Press 'Allow Everywhere' to remember the choice for all workspaces.

If I decline it, the Prettier formatting will not work. Why am I prompted with this since I have Prettier installed as an Extension and not as npm package?

NeNaD
  • 18,172
  • 8
  • 47
  • 89

1 Answers1

1

it is the VS Code extension and not some npm package?

The opposite is true. Prettier is not a VS Code extension. The extension is a bridge (integration) between your editor and the Prettier package installed in the project. In different projects, different versions of Prettier are installed, so to make sure all the collaborators get the same formatting, the local version must always be used. On the other hand, running code from node_modules in VS Code is a certain security risk (e.g., think of a malicious fork of Prettier), so the extension makes the user aware of that. You didn't see this prompt before because it has been added recently.

thorn0
  • 9,362
  • 3
  • 68
  • 96
  • As I said, I have Prettier installed as VS Code Extension and not as npm package. There is also the `prettier` npm package, but I used only Prettier Extension up until now without the package installed in my projects. – NeNaD Apr 08 '21 at 13:42
  • Your approach is okay only if you're the only person who works on these projects. Otherwise there are bound to be formatting conflicts. Or are you saying that the file `my_project_folder/node_modules/prettier/index.js` actually didn't exist? – thorn0 Apr 08 '21 at 14:40
  • Maybe it exists since it is a `node_module` folder, so even if I did not install it explicitly, maybe I have installed some package that uses it so `prettier` package was also installed. But the point is that before I did not need to `Allow` anything and everything worked just fine. But, If I don't `Allow` it, formatting does not work. – NeNaD Apr 12 '21 at 01:00
  • It worked fine using the version from `node_modules`. You just didn't know about that. Now you know, that's what has changed. – thorn0 Apr 12 '21 at 11:01