版本号
~ 最新版
什么问题
~ Yapi二次开发,引入monaco-editor ,【@monaco-editor/react】报错 Module parse failed You may need an appropriate loader to handle this file type
本地用create-app创建一个工程,不报错
ykit是有什么特殊配置导致?
如何复现此问题
~
Step1 安装包: npm install @monaco-editor/react
Step2 组件代码
`
import React from 'react';
import MonacoEditor from '@monaco-editor/react';
const MoEditor = () => {
const classes = {
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'space-between',
padding: 5,
'padding-top': 15,
'margin-bottom': 15,
};
const language = 'javascript';
const examples = `// code here `
return (
<div className={classes.root}>
<MonacoEditor
height="100vh"
path={language}
defaultValue={examples || ''}
defaultLanguage={language}
/>
</div>
)
}
export default MoEditor;
`
Step3 在主页面homejs引入 Moditor组件
启动dev-clinet 报错
`
[error] in ./~/@monaco-editor/react/lib/cjs/DiffEditor/DiffEditor.js
Module parse failed: D:\code\yapi-code\vendors\node_modules\@monaco-editor\react\lib\cjs\DiffEditor\DiffEditor.js Unexpec
ted token (102:6)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (102:6)
@ ./~/@monaco-editor/react/lib/cjs/DiffEditor/index.js 6:17-43
[error] in ./~/@monaco-editor/react/lib/cjs/Editor/Editor.js
Module parse failed: D:\code\yapi-code\vendors\node_modules\@monaco-editor\react\lib\cjs\Editor\Editor.js Unexpected toke
n (116:6)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (116:6)
@ ./~/@monaco-editor/react/lib/cjs/Editor/index.js 6:13-35
× [17:12:44] 3 errors in compiling process.
`
什么浏览器
~ chrome
什么系统(Linux, Windows, macOS)
~ window
暂无答案!
目前还没有任何答案,快来回答吧!