Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

LSP Error: Could not load Prettier: Error: Cannot find module 'prettier' when using astro-ls in neovim #77

Closed
tsndr opened this issue Feb 25, 2024 · 0 comments · Fixed by #81

Comments

@tsndr
Copy link

tsndr commented Feb 25, 2024

Hey,

when using astro in neovim the language server crashes with this error:

[ERROR][2024-02-25 18:56:28] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/toby/.local/share/nvim/mason/bin/astro-ls"	"stderr"	"/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/volar-service-prettier/index.js:18
                throw new Error(\"Could not load Prettier: \" + e);
                      ^

Error: Could not load Prettier: Error: Cannot find module 'prettier'
Require stack:
- /Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/volar-service-prettier/index.js
- /Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/dist/languageServerPlugin.js
- /Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/dist/nodeServer.js
- /Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/bin/nodeServer.js
    at Object.create (/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/volar-service-prettier/index.js:18:23)
    at createServiceContext (/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-service/lib/languageService.js:156:65)
    at createLanguageService (/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-service/lib/languageService.js:39:21)
    at Object.getLanguageService (/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/lib/project/typescriptProject.js:74:76)
    at sendDocumentDiagnostics (/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/lib/server.js:278:66)
    at async updateDiagnostics (/Users/toby/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/lib/server.js:267:13)

Node.js v21.6.2
"

I was able to fix this by doing this:

$ cd ~/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/volar-service-prettier
$ npm install

Maybe this is some kind of dependency issue?

Let me know if you need more information, I would really love to see this resolved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant