uniapp bug解决:uniapp文件查找失败:‘uview-ui‘ at main.js:14

文章目录

  • 报错内容
  • 解决方法
      • [`main.js` 文件中 uView 主 JS 库](#main.js 文件中 uView 主 JS 库)
      • [引入 uView 的全局 `SCSS` 主题文件内容修改](#引入 uView 的全局 SCSS 主题文件内容修改)
      • [引入 uView 基础样式内容修改](#引入 uView 基础样式内容修改)
      • [配置` easycom `内容修改](#配置easycom内容修改)

报错内容

json 复制代码
10:50:51.795 文件查找失败:'uview-ui' at main.js:14
10:59:39.570 正在差量编译...
10:59:43.213 文件查找失败:'uview-ui' at main.js:14
10:59:43.243 正在差量编译...
10:59:45.464 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:45.464 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:45.464         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:45.464         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\App.vue
10:59:45.464 >> @import 'uview-ui/theme.scss';
10:59:45.464    ^
10:59:45.464 文件查找失败:'uview-ui' at main.js:14
10:59:45.493 正在差量编译...
10:59:45.524 Error: getaddrinfo ENOTFOUND 96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com
10:59:45.524     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
10:59:45.524   errno: -3008,
10:59:45.524   code: 'ENOTFOUND',
10:59:45.524   syscall: 'getaddrinfo',
10:59:45.524   hostname: '96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com'
10:59:45.524 }
10:59:46.103 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.103 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.103         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.103         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\App.vue
10:59:46.103 >> @import 'uview-ui/theme.scss';
10:59:46.103    ^
10:59:46.103 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.103 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.103         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.103         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\components\uniapp-zaudio\zaudio.vue
10:59:46.103 >> @import 'uview-ui/theme.scss';
10:59:46.103    ^
10:59:46.103 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.103 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.103         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.103         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages2\customMotion\index.vue
10:59:46.103 >> @import 'uview-ui/theme.scss';
10:59:46.103    ^
10:59:46.103 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.104 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.104         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.104         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages2\foodReplace\index.vue
10:59:46.104 >> @import 'uview-ui/theme.scss';
10:59:46.104    ^
10:59:46.104 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.104 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.104         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.104         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages2\healthyLife\index.vue
10:59:46.104 >> @import 'uview-ui/theme.scss';
10:59:46.104    ^
10:59:46.104 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.104 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.104         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.104         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages2\healthyLife\text.vue
10:59:46.104 >> @import 'uview-ui/theme.scss';
10:59:46.104    ^
10:59:46.104 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.104 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.104         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.104         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages2\stageInfo\stageInfo.vue
10:59:46.104 >> @import 'uview-ui/theme.scss';
10:59:46.104    ^
10:59:46.104 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.104 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.104         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.104         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages2\stageInfo\stageInfotext.vue
10:59:46.104 >> @import 'uview-ui/theme.scss';
10:59:46.104    ^
10:59:46.104 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.104 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.105         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.105         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\breakfastPage\index.vue
10:59:46.105 >> @import 'uview-ui/theme.scss';
10:59:46.105    ^
10:59:46.105 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.105 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.105         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.105         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\checkInSharing\index.vue
10:59:46.105 >> @import 'uview-ui/theme.scss';
10:59:46.105    ^
10:59:46.105 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.105 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.105         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.105         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\dinnerPage\index.vue
10:59:46.105 >> @import 'uview-ui/theme.scss';
10:59:46.105    ^
10:59:46.105 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.105 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.105         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.105         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\drinkPage\index.vue
10:59:46.105 >> @import 'uview-ui/theme.scss';
10:59:46.105    ^
10:59:46.105 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.105 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.105         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.105         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\foodPage\index.vue
10:59:46.105 >> @import 'uview-ui/theme.scss';
10:59:46.105    ^
10:59:46.105 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.105 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.106         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.106         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\lunchPage\index.vue
10:59:46.106 >> @import 'uview-ui/theme.scss';
10:59:46.106    ^
10:59:46.106 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.106 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.106         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.106         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\sleepPage\index.vue
10:59:46.106 >> @import 'uview-ui/theme.scss';
10:59:46.106    ^
10:59:46.106 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.106 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.106         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.106         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\sportPage\index.vue
10:59:46.106 >> @import 'uview-ui/theme.scss';
10:59:46.106    ^
10:59:46.106 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.106 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.106         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.106         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\components\weightPage\index.vue
10:59:46.106 >> @import 'uview-ui/theme.scss';
10:59:46.106    ^
10:59:46.106 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.106 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.106         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.106         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkInDetails\index.vue
10:59:46.106 >> @import 'uview-ui/theme.scss';
10:59:46.107    ^
10:59:46.107 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.107 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.107         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.107         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\checkIn\index.vue
10:59:46.107 >> @import 'uview-ui/theme.scss';
10:59:46.107    ^
10:59:46.107 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.107 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.107         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.107         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\index\index.vue
10:59:46.107 >> @import 'uview-ui/theme.scss';
10:59:46.107    ^
10:59:46.107 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.107 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.107         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.107         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\searchMeals\index.vue
10:59:46.107 >> @import 'uview-ui/theme.scss';
10:59:46.107    ^
10:59:46.107 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.107 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.107         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.107         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\pages\stage\index\index.vue
10:59:46.107 >> @import 'uview-ui/theme.scss';
10:59:46.107    ^
10:59:46.107 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.107 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.107         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.107         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-file-picker\components\uni-file-picker\upload-file.vue
10:59:46.107 >> @import 'uview-ui/theme.scss';
10:59:46.108    ^
10:59:46.108 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.108 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.108         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.108         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-file-picker\components\uni-file-picker\upload-image.vue
10:59:46.108 >> @import 'uview-ui/theme.scss';
10:59:46.108    ^
10:59:46.108 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.108 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.108         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.108         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-forms\components\uni-forms-item\uni-forms-item.vue
10:59:46.108 >> @import 'uview-ui/theme.scss';
10:59:46.108    ^
10:59:46.108 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.108 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.108         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.108         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-forms\components\uni-forms\uni-forms.vue
10:59:46.108 >> @import 'uview-ui/theme.scss';
10:59:46.108    ^
10:59:46.108 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.108 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.108         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.108         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-icons\components\uni-icons\uni-icons.vue
10:59:46.108 >> @import 'uview-ui/theme.scss';
10:59:46.108    ^
10:59:46.108 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.108 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.108         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.108         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-notice-bar\components\uni-notice-bar\uni-notice-bar.vue
10:59:46.109 >> @import 'uview-ui/theme.scss';
10:59:46.109    ^
10:59:46.109 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
10:59:46.109 SassError: File to import not found or unreadable: uview-ui/theme.scss.
10:59:46.109         on line 2 of C:/Users/Administrator/Desktop/uniapp-food/uni.scss
10:59:46.109         from line 51 of C:\Users\Administrator\Desktop\uniapp-food\uni_modules\uni-popup\components\uni-popup\uni-popup.vue
10:59:46.109 >> @import 'uview-ui/theme.scss';
10:59:46.109    ^
10:59:46.109 文件查找失败:'uview-ui' at main.js:14
10:59:46.109 Error: getaddrinfo ENOTFOUND 96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com
10:59:46.109     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
10:59:46.109   errno: -3008,
10:59:46.109   code: 'ENOTFOUND',
10:59:46.109   syscall: 'getaddrinfo',
10:59:46.109   hostname: '96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com'
10:59:46.109 }
11:02:59.542 正在差量编译...
11:03:01.289 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js):
11:03:01.289 SassError: File to import not found or unreadable: uview-ui/index.scss.
11:03:01.289         on line 82 of C:\Users\Administrator\Desktop\uniapp-food\App.vue
11:03:01.289 >> @import "uview-ui/index.scss";
11:03:01.289    ^
11:03:01.289 文件查找失败:'uview-ui' at main.js:14
11:03:01.331 Error: getaddrinfo ENOTFOUND 96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com
11:03:01.331     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
11:03:01.331   errno: -3008,
11:03:01.331   code: 'ENOTFOUND',
11:03:01.331   syscall: 'getaddrinfo',
11:03:01.331   hostname: '96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com'
11:03:01.331 }
11:03:32.685 正在差量编译...
11:03:33.795 文件查找失败:'uview-ui' at main.js:14

解决方法

改成具体文件路径即可

整合以上内容到一个完整的配置步骤中,以便在 UniApp 项目中引入和配置 uView UI 库:

main.js 文件中 uView 主 JS 库

在项目根目录中的 main.js 文件中引入并使用 uView 的 JS 库。

javascript 复制代码
// main.js
import Vue from 'vue';
import uView from '@/uni_modules/uview-ui';

Vue.use(uView);

引入 uView 的全局 SCSS 主题文件内容修改

在项目根目录的 uni.scss 文件中引入 uView 的 SCSS 主题文件。

scss 复制代码
/* uni.scss */
@import '@/uni_modules/uview-ui/theme.scss';

引入 uView 基础样式内容修改

App.vue 中的 <style> 标签中的首行位置引入 uView 的基础样式,确保给 <style> 标签加入 lang="scss" 属性。

vue 复制代码
<!-- App.vue -->
<style lang="scss">
  /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  @import "@/uni_modules/uview-ui/index.scss";
</style>

配置easycom内容修改

在项目根目录的 pages.json 文件中配置 easycom 组件模式,确保 uView 的组件可以在项目中被正确引用。

json 复制代码
// pages.json
{
  "easycom": {
    "^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
  },
  
  // 此为本身已有的内容
  "pages": [
    // ......
  ]
}

全部改好就正常了

您好,我是肥晨。

欢迎关注我获取前端学习资源,日常分享技术变革,生存法则;行业内幕,洞察先机。

相关推荐
林小白的日常10 分钟前
uniapp中wx.getFuzzyLocation报错如何解决
前端·javascript·uni-app
Mirilla1 小时前
华为IoTDA 智慧路灯设备SDK与平台通信C 流程bug解决
华为云·bug
ganlanA2 小时前
uniapp+vue 前端防多次点击表单,防误触多次请求方法。
前端·vue.js·uni-app
爱吃鱼的酱酱仔2 小时前
uniapp实现APP、小程序与webview页面间通讯
小程序·uni-app
梦起丶2 小时前
Qt 中实现系统主题感知
qt·ui·工具·qml
MediaTea6 小时前
Ps:在 Photoshop 中编辑视频
ui·音视频·photoshop
贾宝玉的玉宝贾8 小时前
FreeSWITCH 简单图形化界面38 - 使用uniapp中使用JsSIP进行音视频呼叫
uni-app·音视频·voip·freeswitch·ippbx·jssip
xfxTab10 小时前
uniapp中Nvue白屏问题 ReferenceError: require is not defined
uni-app
Unity_RAIN20 小时前
Unity 战斗系统中角色UI血条设计
ui·unity·游戏引擎
于慨20 小时前
uniapp打包h5应用如何开启history模式,以及资源管理器直接打开存在问题
uni-app