Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Errors with Error: Cannot find module 'prettier' after prettierd's update #816

Open
gegoune opened this issue Nov 18, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@gegoune
Copy link

gegoune commented Nov 18, 2024

HI there,

I have noticed an issue running prettierd recently, seems like installed paths are not quite matching package version:

❯ brew install fsouza/prettierd/prettierd
==> Fetching fsouza/prettierd/prettierd
==> Downloading https://registry.npmjs.org/@fsouza/prettierd/-/prettierd-0.25.4.tgz
[...]
❯ cat foo.js | prettierd foo.js
Error: Cannot find module 'prettier'
Require stack:
- /opt/homebrew/Cellar/prettierd/0.25.3/libexec/lib/node_modules/@fsouza/prettierd/dist/service.js
- /opt/homebrew/Cellar/prettierd/0.25.3/libexec/lib/node_modules/@fsouza/prettierd/node_modules/core_d/lib/server.js
- /opt/homebrew/Cellar/prettierd/0.25.3/libexec/lib/node_modules/@fsouza/prettierd/node_modules/core_d/lib/daemon.js
❯ ls -d /opt/homebrew/Cellar/prettierd/0.25.*
/opt/homebrew/Cellar/prettierd/0.25.4

Please note that no directory for version 0.25.4 is present when installed with Homebrew.


Thanks for prettierd, it's amazing!

@timharek
Copy link

timharek commented Dec 4, 2024

I have the same issue with macOS with Homebrew.

cc @fsouza

@fsouza
Copy link
Owner

fsouza commented Jan 4, 2025

hmm it looks like something broke with the upgrade? What are the contents of the prettierd prefix? Something like:

$ ls -l $(brew --prefix prettierd)

@gegoune
Copy link
Author

gegoune commented Jan 4, 2025

That's pretty interesting now. I am no longer convinced is an issue with prettierd itself, but perhaps with homebrew instead.

I was just about to reply to your message, and have tested it just like in original post, and it worked just fine so I decided to upgrade to 0.26.0, which broke it once again, in the same fashion:

❯ cat test.js | prettierd test.js
Error: Cannot find module 'prettier'
Require stack:
- /opt/homebrew/Cellar/prettierd/0.25.4/libexec/lib/node_modules/@fsouza/prettierd/dist/service.js
- /opt/homebrew/Cellar/prettierd/0.25.4/libexec/lib/node_modules/@fsouza/prettierd/node_modules/core_d/lib/server.js
- /opt/homebrew/Cellar/prettierd/0.25.4/libexec/lib/node_modules/@fsouza/prettierd/node_modules/core_d/lib/daemon.js

❯ which prettierd
/opt/homebrew/bin/prettierd

❯ ls -l /opt/homebrew/bin/prettierd
lrwxr-xr-x 1 gegoune admin 40 Jan  4 11:38 /opt/homebrew/bin/prettierd -> ../Cellar/prettierd/0.26.0/bin/prettierd

❯ prettierd --version
prettierd 0.26.0

❯ ls -l $(brew --prefix prettierd)
lrwxr-xr-x 1 gegoune admin 26 Jan  4 11:33 /opt/homebrew/opt/prettierd -> ../Cellar/prettierd/0.26.0

@fsouza
Copy link
Owner

fsouza commented Jan 5, 2025

Can you try running prettierd stop or just pkill prettierd? If that fixes it, it's possible it's an issue with the caching, maybe we should detect that the cached prettier is gone and handle it.

@gegoune
Copy link
Author

gegoune commented Jan 5, 2025

Oh, that fixed that indeed! Thank you!
I will make mental note to run it after next update, but would be nice to handle it internally like you said. Let me update this issue's subject to better describe the issue.

@gegoune gegoune changed the title Issue running version 0.25.4 Errors with Error: Cannot find module 'prettier' after prettierd's update Jan 5, 2025
@fsouza fsouza added the bug Something isn't working label Jan 5, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants