monaco-react: Use monaco-editor as a local package, but a worker-related error occurs
Describe the bug I refer to the usage method in the documentation and use monaco-editor as a local package. The following is the sample code:
import * as monaco from 'monaco-editor';
import MonacoEditor, { loader } from '@monaco-editor/react';
loader.config({
monaco,
});
But after using it in my project, it produces the following error:
Uncaught (in promise) Error: Unexpected usage
at EditorSimpleWorker.loadForeignModule (editorSimpleWorker.js:460:1)
at webWorker.js:38:1
Screenshots

Desktop
- OS: [macOS]
- Browser [Chrome]
- Version [105.0.5195.102]
Additional context
- @monaco-editor/react@4.4.5
- monaco-editor@0.33.0
- Created by CRA eject mode
Is there any good way to solve the above problem?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (2 by maintainers)
I resolved this error in
esbuild