如图,记录下。
环境
"vue": "^3.2.47"
"element-plus": "^2.3.6"
"vite-plugin-qiankun": "^1.0.15"
"vite": "^4.3.9"
解决方式一:
有人这么说:(我这里并没有好用)
"vite-plugin-qiankun": "1.0.15" 这个版本已经用了一年多,今天突然打包时报错报错原因是引用了undici ,我发现是包里引用了cheerio库 "cheerio": "^1.0.0-rc.10" ,cheerio 3天前更新了最新版本1.0.0之后。就出现该问题
需要指定cheerio版本,在package.json 添加 resolutions 字段,指定 cheerio 的版本:
resolutions是和 dependencies同级的
"resolutions": {
"cheerio": "1.0.0-rc.12"
}
解决方式二:
有人这么说:(我不愿意,是不是有点没办法了?但是方法确实可以)
升级node版本 18+(我这里本身16.15.0)
解决方式二:
有人这么说:(我采用的)
删除 node_modules
删除 package-lock.json
执行 npm cache clean -f
执行 npm install
执行 npm i cheerio@1.0.0-rc.10
以上到此就算是解决了:Error: ReferenceError: ReadableStream is not defined
这时候或许会报警告:
Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
大致意思是:在vue3+vite项目中,使用低sass版本低于2.0.0的,会有上面这个警告
解决方式:(我用的是方法二)
方法一:
export default defineConfig(({ mode }) => {
``````
return {
``````
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler' // or "modern"
},
},
},
``````
}
``````
})
方法二:
export default defineConfig(({ mode }) => {
``````
return {
``````
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api'],
},
},
},
``````
}
``````
})
这个时候,基本解决了以上问题。如有其他错误欢迎探讨!!!