Monaco editor (via @monaco-editor/react) is showing Error: Could not find source file: ‘inmemory://model/2’?

I keep getting this every time the monaco <Editor react component gets passed a new value string:

Uncaught (in promise) Error: Could not find source file: 'inmemory://model/2'.
    at je (tsWorker.js:254:8493)
    at Object.kn [as getSyntacticDiagnostics] (tsWorker.js:254:13349)
    at um.getSyntacticDiagnostics (tsWorker.js:33954:2557)
    at _.fmr (workerMain.js:22:32298)
    at g.d (workerMain.js:22:17052)
    at Object.handleMessage (workerMain.js:22:16773)
    at S.k (workerMain.js:22:14026)
    at S.h (workerMain.js:22:13657)
    at S.handleMessage (workerMain.js:22:13589)
    at g.onmessage (workerMain.js:22:16833)

Do I need to add something to my build step somewhere? I am using Next.js if that’s relevant, already with a custom webpack config.

enter image description here

I literally just am using it in a functional React component after doing import Editor from '@monaco-editor/react'.

If it matters at all, I am going to have multiple editors on the screen at once, and each editor can be toggled between several languages. I feel like it has something to do with the model because of the error message, but the docs don’t suggest that you need to manually configure a model file load for web workers or anything, so not sure.

  • Sounds like you are working with a model that doesn’t exist (anymore). From the stack it looks like this is happening in a worker. Is that yours or one from Monaco?

    – 

Leave a Comment