Intellisense stopped working when I tried to use node_modules version instead of CDN
Everything works fine until I tried to setup the loader to use the node_modules version.
import * as monaco from "monaco-editor"
// both didnt work
loader.config({ monaco })
loader.config({
paths: {
vs: "node_modules/monaco-editor/min/vs"
}
})
self.MonacoEnvironment = {
getWorker(_, label) {
console.log(label) //? this returns editorWorkerService
if (label === "typescript" || label === "javascript") {
return new tsWorker()
}
return new editorWorker()
}
}
// ...
// no intellisense
<MonacoEditor
language="javascript" // here I specified to use js only
path="script.js"
/>
I'm using monaco-editor 0.41.0, @monaco-editor/react 4.5.2, vite 4.4.4. This is on a tauri app if that's relevant.
do you see any errors/warnings in the console?
nope. I suspect there might be something going on with the worker that made it not be able to load because when I used the cdn ver, it did log javascript and typescript to the console.
I also tried to move the whole monaco-editor folder to public and config the loader
loader.config({
paths: {
vs: "/monaco-editor/min/vs"
}
})
but the result was the same. The language worker did not work.
somehow when I downgraded to v0.38.0 (same version with the cdn) this works.
I also tried to move the whole monaco-editor folder to public and config the loader
loader.config({ paths: { vs: "/monaco-editor/min/vs" } })but the result was the same. The language worker did not work.
Also experiencing the same issue. Downgrading monaco-editor to 0.40.0 restores intellisense
My experience is that the editor doesn't recognize "json" as the first language that is requested (loading only the base worker, and not jsonMode). A weird workaround I found was to
- Create an editor setting it to a language other than "json" (in my case "mermaid")
- And then creating the one with the "json" language and it loads jsonMode and the worker as expected
Update: this was resolved in monaco-editor @ 0.42 See: https://github.com/microsoft/monaco-editor/issues/4159 (Probably can resolve this issue here since it's not related to monaco-react)
Update: this was resolved in monaco-editor @ 0.42 See: [microsoft/monaco-editor#4159]
Thanks for the pointer. Upgrading monaco-editor to latest (0.43.0) resurrected intellisense for me.
This issue has been marked as stale due to inactivity. It will be closed in 7 days unless further activity occurs.
Closing due to inactivity. Feel free to reopen if needed.