目前使用的版本:
“monaco-editor”: “^0.28.1”,
“monaco-editor-webpack-plugin”: “^4.2.0”,
遇上第1个报错:
Cannot find module ‘vs/editor/contrib/inlineHints/inlineHintsController‘
解决办法:npm list --depth 0 查看本地包对应的依赖 → 按照提示,只需要去官网下载响应的版本即可。https://www.npmjs.com/package/monaco-editor-webpack-plugin
遇上第2个报错
Unexpected usage at EditorSimpleWorker.loadForeignModule
解决方案:
// vue.config.js
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
module.exports = {
chainWebpack(config) {
config.plugin('monaco').use(new MonacoWebpackPlugin())
},
}
参考来自两个博主:
https://blog.csdn.net/m0_45236510/article/details/115049181
https://blog.csdn.net/qq_43530269/article/details/118031013