报错15:13:31.266 Module Error (from ./node_modules/@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style.js): 15:13:31.267 (Emitted value instead of an instance of Error) Error: undefined:153:5: missing '}',Error: undefined:174:9: missing '}' 15:13:31.276 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/sass-loader/dist/cjs.js): 15:13:31.285 ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema. 15:13:31.285 - options has an unknown property 'additionalData'. These properties are valid: 15:13:31.291 object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter?, nvue? } 15:13:31.291 at validate (E:\whg\ChuangQi\app\ybgdd-ai\front\node_modules\@dcloudio\vue-cli-plugin-uni\packages\sass-loader\node_modules\schema-utils\dist\validate.js:96:11) 15:13:31.298 at Object.loader (E:\whg\ChuangQi\app\ybgdd-ai\front\node_modules\@dcloudio\vue-cli-plugin-uni\packages\sass-loader\dist\index.js:38:28)
时间: 2023-11-26 13:06:43 浏览: 1056
这个错误是由于sass-loader的配置不正确导致的。具体而言,错误信息指出了sass-loader的options对象中包含了一个未知属性additionalData,这个属性不在API schema中定义,因此引起了ValidationError。
要解决这个问题,可以尝试在webpack配置中修改sass-loader的options,将additionalData属性改为prependData属性,并将sass的变量定义放在prependData中,例如:
```
// vue.config.js
module.exports = {
chainWebpack: config => {
config.module
.rule('scss')
.use('sass-loader')
.tap(options =>
Object.assign(options, {
prependData: `
@import "@/styles/variables.scss";
`
})
)
}
}
```
这里的变量定义文件路径为src/styles/variables.scss,你需要根据实际情况进行修改。
希望这个解决方案能够帮助你解决问题。如果还有其他问题,请随时提出。
相关问题
Module Error (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):
回答: Module Error (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js)是一个报错信息。根据引用的描述,这个错误可能是由于使用了Vue语法而导致的。你可以尝试去Vue语法文档中查找解决方法。在Vue3基础文档中,你可能能找到关于这个错误的原因和解决方案。希望这个回答对你有帮助!<span class="em">1</span>
#### 引用[.reference_title]
- *1* [HBuilder编译uniapp 报错Module Error :Errors compiling template:(最终根本原因)](https://blog.csdn.net/m0_73034508/article/details/126735541)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
Error: pages.json解析失败,不符合 json 规范 10:15:30.108 Unexpected token ] in JSON at position 8800 10:15:30.111 at getJson (C:\develop\HBuilderX.3.8.3.20230526\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-cli-shared\lib\json.js:35:11) 10:15:30.112 at getPagesJson (C:\develop\HBuilderX.3.8.3.20230526\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-cli-shared\lib\pages.js:39:27) 10:15:30.115 at Object.<anonymous> (C:\develop\HBuilderX.3.8.3.20230526\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\lib\env.js:201:22) 10:15:30.116 at Module._compile (node:internal/modules/cjs/loader:1126:14) 10:15:30.120 at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) 10:15:30.120 at Module.load (node:internal/modules/cjs/loader:1004:32) 10:15:30.125 at Function.Module._load (node:internal/modules/cjs/loader:839:12) 10:15:30.125 at Module.require (node:internal/modules/cjs/loader:1028:19) 10:15:30.130 at require (node:internal/modules/cjs/helpers:102:18) 10:15:30.130 at Object.<anonymous> (C:\develop\HBuilderX.3.8.3.20230526\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\index.js:5:5) 10:15:30.135 Error: getaddrinfo ENOTFOUND 96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com 10:15:30.136 at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) { 10:15:30.141 errno: -3008, 10:15:30.141 code: 'ENOTFOUND', 10:15:30.146 syscall: 'getaddrinfo', 10:15:30.146 hostname: '96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com' 10:15:30.150 } 报错解释
这段报错信息包含两个错误。第一个错误是 pages.json 解析失败,不符合 json 规范,具体错误是在第 8800 个字符位置出现了一个意外的 ] 符号。第二个错误是 getaddrinfo ENOTFOUND,表示无法解析主机名 96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com。这可能是因为网络问题或者主机名拼写错误导致的。
阅读全文