react18项目中引入插件后控制台eslint警告:Failed to parse source map from...

react18中引入antv-x6和antd后报警告:Compiled with warnings.

控制台报如下错误:

WARNING in ./node_modules/@antv/x6-react-shape/es/view.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\yunlu\Desktop\yuntuan\yuntuan-react\node_modules\@antv\x6-react-shape\src\view.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\yunlu\Desktop\yuntuan\yuntuan-react\node_modules\@antv\x6-react-shape\src\view.ts'
WARNING in ./node_modules/antd/dist/antd.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./node_modules/antd/dist/antd.css)
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map: 'webpack://antd/./components/time-picker/style/index.less' URL is not supported

看起来是source map和node_modules的错误,所以我们改一下webpack.config.js中的source map配置

找到source map配置后,在exclude中把node_modules文件夹添加进去,表示忽略这个文件夹下的文件内容

在这里插入图片描述

exclude: [/@babel(?:/|\{1,2})runtime/,/node_modules/],

然后再npm start,发现警告已经没有了!

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_38318244/article/details/125642441