You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I followed the readme and tried to configure the prettier plugin globally. For this I installed prettier and prettier-plugin-javaglobally with npm -g and added the file prettierrc.yaml to the root directory with the following content as described in the readme:
plugins:
- prettier-plugin-java
When I run prettier --write "**/*.java" in the root directory I see the following error: [error] Cannot find package 'prettier-plugin-java' imported from /Users/currentuser/projectroot/noop.js
It seems that it tries to load the plugin from the project directory and not from the global node_modules which is quite annoying. As others do not seem to have this kind of issue, this might only occur on macOS ?
When changing the plugin path in the prettierrc.yaml to an absolute path it works as expected:
However, this means that the file cannot be checked into Git and every developer has to configure the file since everyone has different paths; I cannot even replace /Users/currentuser with ~ , this also throws the same error.
Do you know how I can make it work on macOS so that I can only use the short version and do not need the absolute path? If there is no way to make it work, the documentation of this project should be adjusted and this issue must be described in the readme. It took me way too long to figure out how to get rid of the error.
The text was updated successfully, but these errors were encountered:
This appears to be an issue with the way Prettier itself loads plugins: prettier/prettier#15141 A workaround is to install the plugin in your home directory instead of globally. That seems to allow Prettier to find the plugin without issue. For example:
Thanks for bringing this to our attention! We should update Prettier Java's README to instruct users to follow the above steps, since apparently installing both Prettier and the plugin globally no longer works (I'm guessing this is an issue with Prettier 3.)
Hello, I followed the readme and tried to configure the prettier plugin globally. For this I installed
prettier
andprettier-plugin-java
globally withnpm -g
and added the fileprettierrc.yaml
to the root directory with the following content as described in the readme:When I run
prettier --write "**/*.java"
in the root directory I see the following error:[error] Cannot find package 'prettier-plugin-java' imported from /Users/currentuser/projectroot/noop.js
It seems that it tries to load the plugin from the project directory and not from the global node_modules which is quite annoying. As others do not seem to have this kind of issue, this might only occur on macOS ?
When changing the plugin path in the
prettierrc.yaml
to an absolute path it works as expected:However, this means that the file cannot be checked into Git and every developer has to configure the file since everyone has different paths; I cannot even replace
/Users/currentuser
with~
, this also throws the same error.Do you know how I can make it work on macOS so that I can only use the short version and do not need the absolute path? If there is no way to make it work, the documentation of this project should be adjusted and this issue must be described in the readme. It took me way too long to figure out how to get rid of the error.
The text was updated successfully, but these errors were encountered: