文章目录
- 报错内容
- 解决方法
- `main.js` 文件中 uView 主 JS 库
- 引入 uView 的全局 `SCSS` 主题文件内容修改
- 引入 uView 基础样式内容修改
- 配置` easycom `内容修改
报错内容
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 库。
// main.js
import Vue from 'vue';
import uView from '@/uni_modules/uview-ui';Vue.use(uView);
引入 uView 的全局 SCSS
主题文件内容修改
在项目根目录的 uni.scss
文件中引入 uView 的 SCSS 主题文件。
/* uni.scss */
@import '@/uni_modules/uview-ui/theme.scss';
引入 uView 基础样式内容修改
在 App.vue
中的 <style>
标签中的首行位置引入 uView 的基础样式,确保给 <style>
标签加入 lang="scss"
属性。
<!-- App.vue -->
<style lang="scss">/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */@import "@/uni_modules/uview-ui/index.scss";
</style>
配置easycom
内容修改
在项目根目录的 pages.json
文件中配置 easycom 组件模式,确保 uView 的组件可以在项目中被正确引用。
// pages.json
{"easycom": {"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"},// 此为本身已有的内容"pages": [// ......]
}
全部改好就正常了
您好,我是肥晨。
欢迎关注我获取前端学习资源,日常分享技术变革,生存法则;行业内幕,洞察先机。