11:34:05.798 [vite]: Rollup failed to resolve import "axios" from "E:/桌面/111/live-chat-master/uniapp/chatroomwx/pages/chatroom/chatroom.vue". 11:34:05.799 This is most likely unintended because it can break your application at runtime. 11:34:05.800 If you do want to externalize this module explicitly add it to 11:34:05.800 `build.rollupOptions.external`
时间: 2024-01-31 09:04:33 浏览: 838
这个错误提示是因为在你的 Chatroom.vue 文件中使用了 axios 模块,但是 Rollup 找不到该模块的引用。你需要将 axios 模块添加到 build.rollupOptions.external 中。
在你的 vite.config.js 文件中添加如下代码:
```javascript
export default {
build: {
rollupOptions: {
external: ['axios']
}
}
}
```
这样就可以解决这个问题了。
相关问题
17:57:38.451 [vite]: Rollup failed to resolve import "axios" from "E:/桌面/111/live-chat-master/uniapp/chatroomwx/pages/chatroom/chatroom.vue". 17:57:38.453 This is most likely unintended because it can break your application at runtime. 17:57:38.453 If you do want to externalize this module explicitly add it to 17:57:38.455 `build.rollupOptions.external`
这是一个 Rollup 打包错误,因为在你的 chatroom.vue 文件中引入了 axios 模块,但是 Rollup 在打包时无法解析它。你可以通过在你的 `vite.config.js` 文件中的 `build.rollupOptions.external` 中添加 axios 来显式地将其排除在打包之外,如下所示:
```javascript
export default {
build: {
rollupOptions: {
external: ['axios'] // 添加 axios 到 external 中
}
}
}
```
这样 Rollup 就会在打包时跳过对 axios 的处理,而是在运行时从外部获取它。
uniapp中报错 [vite]: Rollup failed to resolve import "dayjs" from "F:/jiuxiaoma-worker_mini/uni_modules/uview-plus/components/u-calendar/u-calendar.vue".
这个错误提示是在使用 Vite 构建 Uniapp 项目时出现的,提示 Rollup 无法从指定路径中找到 dayjs 模块。
解决方法如下:
1. 确认是否已经在项目中安装了 dayjs 模块,如果没有,请使用 npm 或 yarn 安装:
```
npm install dayjs --save
```
2. 如果已经安装了 dayjs 模块,可以尝试在 `vite.config.js` 中添加以下配置:
```javascript
export default {
// ...
optimizeDeps: {
include: ['dayjs']
}
}
```
这个配置可以让 Vite 在打包时将 dayjs 模块包含进去。
3. 如果以上两种方法都没有解决问题,可以尝试更新 Vite 到最新版本,或者降级到较旧的版本。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)