-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Error: Missing service editorService" when using monaco-languageclient in production Stage #870
Comments
Hi everyone, I've managed to resolve the "Error: Missing service editorService" issue I reported in this thread (#870). It turns out the solution was quite simple. Solution: The issue can be fixed by adding Here's the corrected code snippet: const DynamicEditor = dynamic(
async () => {
await import("vscode"); // Add this line
const monaco = await import("monaco-editor");
const { loader, Editor } = await import("@monaco-editor/react");
loader.config({ monaco });
return Editor;
},
{ ssr: false }
); By adding Important Note: With this fix, you can now successfully use I hope this helps anyone else encountering the same issue. |
Dear @Typefox/monaco-language Developers and Contributors, I'm writing to share a solution I've developed to overcome the challenges of integrating Language Server Protocol (LSP) functionality within Next.js, specifically using @monaco-editor/react and @Typefox/monaco-language, and addressing the complexities of Server-Side Rendering (SSR). I've created a demonstration repository, available here: https://github.com/cfngc4594/monaco-editor-lsp-next, which showcases a working implementation. This repository leverages Docker Compose, enabling straightforward deployment with a single command. I've observed that many developers struggle with SSR-related issues when attempting to integrate LSP into Next.js using these libraries, and I believe this demo could serve as a valuable resource for those facing similar hurdles. I would be immensely grateful if you would consider including this repository as a community-contributed example in the README. I'm confident it could significantly aid others in navigating these integration challenges. Would you be receptive to a pull request to incorporate this into the README? Thank you for your time and consideration. Sincerely, cfngc4594 |
@cfngc4594 thank you. I was on vacation and will have a look this week. |
Hi @kaisalmen , Thank you for taking the time to review my PR. The previous submission was an initial integration of the LSP, but the implementation wasn’t as elegant as it could be. After over a week of real-world usage and refinements, I’ve identified a better approach and plan to update the PR soon. I’d appreciate it if you could hold off on merging for now—I’ll submit the improved version shortly. Thanks for your patience and support! Best regards, |
Hi @cfngc4594 you are talking about #880 right? Can you convert it to a Draft, then it is clear it is not ready. You can also add "WIP:" in the title. |
Hi @kaisalmen , Additionally, I am aware of the current next example, but the current example uses I would like to ask if, in addition to adding documentation, I can also provide an example in the |
@cfngc4594 I think it is best if the documentation refers mostly to executable code and yes, it makes sense to have an independent verification example. And please use current versions. Let's continue any further discussion in the PR. 👍 |
@kaisalmen Okay, I will close the current issue. |
I'm integrating a C language LSP service into my Next.js project using
@monaco-editor/react
andmonaco-languageclient
. Everything works fine inbun run dev
development mode, with no SSR errors and the LSP service functioning correctly.However, when I build and run the project in production using
bun run build
andbun run start
, I encounter the error:Error: Missing service editorService
in the browser console. This prevents the LSP service from working.Reproduction Steps:
docker
directory:cd docker
docker compose up -d
to start the LSP container. This will build and run theclangd
language server.cd ..
bun install
to install dependencies.bun run build
to build the project.bun run start
to start the production server.Expected Behavior:
Error: Missing service editorService
error.Actual Behavior:
Error: Missing service editorService
error, and the LSP service does not work.Environment Information:
Versions of
monaco-editor
andmonaco-languageclient
were chosen after multiple attempts to find a stable and working configurationVersions of
vscode-languageclient
andvscode-ws-jsonrpc
are latest, but they work well in development stagemonaco-editor
version: 0.36.1monaco-languageclient
version: 5.0.1vscode-languageclient
version: ^9.0.1vscode-ws-jsonrpc
version: ^3.4.0Code Snippet:
Additional Context:
"I understand that many developers wish to use Monaco Editor with LSP functionality in Next.js.
@monaco-editor/react
has already optimized for SSR, making it a popular choice for Next.js users. However, the SSR issues introduced by integrating LSP often lead to developers abandoning the integration.Currently, I have not found any successful examples of integrating LSP with
@monaco-editor/react
in Next.js across the entire web. We are now only one step away from success. I plan to develop an open-source online judge for my school (as the school's original online judge is as basic as a notepad, lacking syntax highlighting and other essential features). I've also noticed that most open-source OJs do not prioritize student programming experience and LSP integration. LeetCode seems to offer LSP functionality, but it requires a premium membership. Therefore, I intend to create an open-source code editor OJ with LSP integration. I believe this will be incredibly helpful for college students who are new to programming, especially during exams.I already have a repository that integrates an LSP code editor using React, which also utilizes
@monaco-editor/react
. You can find it here: https://github.com/cfngc4594/monaco-editor-lsp-react. I hope this can be beneficial to others."The text was updated successfully, but these errors were encountered: