关于UNI-APP小程序常见的问题汇总
1:报错:
10:14:28.022 ERROR Error loading vue.config.js:
10:14:28.027 ERROR Error: Cannot find module 'uni-read-pages'
运行:
Npm install uni-read-pages --save-dev --legacy-peer-deps
2:报错
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
或
Vue2 scss 预编译器默认已由 node-sass 更换为 dart-sass,如果您的代码使用了 dart-sass 不支持的旧语法,可能存在部分不兼容的问题。
在manifest.json源码中添加一下代码,
"sassImplementationName": "node-sass"
示例:
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"sassImplementationName": "node-sass",
3:跨域问题
报错:Access to XMLHttpRequest at 'https://ow3c72uxp6.by.takin.cc/zyj-api-web/hzsx/aliPay/index/getIndexActionListByPage?pageNum=1&pageSize=10&channelId=H01' from origin 'https://192.168.100.137:5054' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
跨域问题
1:检查前端跨域配置,正常如下。
traget:本地接口地址
"devServer" : {
"port" : 5054,
"proxy" : {
"/zyj-api-web" : {
"target" : "https://ow3c72uxp6.by.takin.cc/zyj-api-web/", //你的接口地址
"changeOrigin" : true,
"ws" : true,
"pathRewrite" : {
"^/zyj-api-web" : ""
}
}
},
"https" : true
}
2:检查前端baseUrl
baseurl正常情况只写:/zyj-api-web 就OK了
4:报错
ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: eslint-plugin-vue@4.7.1
npm ERR! Found: eslint@5.16.0
npm ERR! node_modules/eslint
npm ERR! dev eslint@"^5.0.1" from the root project
npm ERR! peer eslint@">= 4.12.1" from babel-eslint@10.1.0
npm ERR! node_modules/babel-eslint
npm ERR! dev babel-eslint@"^10.1.0" from the root project
npm ERR! 5 more (eslint-config-standard, eslint-plugin-import, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^3.18.0 || ^4.0.0" from eslint-plugin-vue@4.7.1
npm ERR! node_modules/eslint-plugin-vue
npm ERR! dev eslint-plugin-vue@"^4.5.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@4.19.1
npm ERR! node_modules/eslint
npm ERR! peer eslint@"^3.18.0 || ^4.0.0" from eslint-plugin-vue@4.7.1
npm ERR! node_modules/eslint-plugin-vue
npm ERR! dev eslint-plugin-vue@"^4.5.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/wwwshanshan/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/wwwshanshan/.npm/_logs/2025-08-27T03_42_57_813Z-debug-0.log
运行:
npm install --legacy-peer-deps
# 或者
npm install --force