Currently, globally installed plugins don't seem to be discovered by the CLI:
npm install -g prettier @prettier/plugin-php
prettier --plugin=@prettier/plugin-php --parser=php test.php
# Error: Cannot find module '@prettier/plugin-php'
npm init --yes
npm install prettier @prettier/plugin-php
prettier --plugin=@prettier/plugin-php --parser=php test.php
# works
It seems that read-pkg-up is just looking for the closest package.json file, which doesn't work for global installs
|
const readPkgUp = require("read-pkg-up"); |
(in case you're wondering why i'm explicitly passing the plugin: There also seems to be an issue with automatic discovery, running the command without results in SyntaxError: Unexpected token (see prettier/plugin-php#55))
Currently, globally installed plugins don't seem to be discovered by the CLI:
It seems that
read-pkg-upis just looking for the closestpackage.jsonfile, which doesn't work for global installsprettier/src/common/load-plugins.js
Line 4 in 1b61b81
(in case you're wondering why i'm explicitly passing the plugin: There also seems to be an issue with automatic discovery, running the command without results in
SyntaxError: Unexpected token(see prettier/plugin-php#55))