cczzz
cczzz
  • 发布:2024-03-26 14:10
  • 更新:2024-03-26 14:41
  • 阅读:550

【报Bug】升级到4.06后,cli调用了vite不存在的接口报错

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 11

HBuilderX类型: 正式

HBuilderX版本号: 4.06

第三方开发者工具版本号:

基础库版本号:

项目创建方式: HBuilderX

操作步骤:

预期结果:

实际结果:

bug描述:

cli工程
此前使用3.99版本,今天命令行提示有新版本,执行npx @dcloudio/uvm@latest后更新到4.06,重新npm run dev进入dev模式,仍能正常启动本地服务,但是一旦请求任一模块就会报错。
报错如下:

Compiler version: 4.06(vue3)  
Compiling...  

  vite v4.0.3 dev server running at:  

  ➜  Local:   http://localhost:80/  
  ➜  Network: http://169.254.173.112:80/  
  ➜  Network: http://172.21.0.1:80/  
  ➜  Network: http://169.254.122.209:80/  
  ➜  Network: http://10.1.20.211:80/  
  ➜  Inspect: http://localhost/__inspect/  

  ready in 2334ms.  

C:\Users\q\Desktop\tr-small-store\node_modules\.pnpm\@dcloudio+uni-h5-vite@3.0.0-4000620240325001_postcss@8.4.35_vue@3.2.47\node_modules\@dcloudio\uni-h5-vite\dist\plugins\sourcemap.js:33  
                    const mod = this._server.moduleGraph._getUnresolvedUrlToModule(key);  
                                                         ^  

TypeError: this._server.moduleGraph._getUnresolvedUrlToModule is not a function  
    at C:\Users\q\Desktop\tr-small-store\node_modules\.pnpm\@dcloudio+uni-h5-vite@3.0.0-4000620240325001_postcss@8.4.35_vue@3.2.47\node_modules\@dcloudio\uni-h5-vite\dist\plugins\sourcemap.js:33:58  

Node.js v20.9.0  
 ELIFECYCLE  Command failed with exit code 1.

报错位置如图1

升级产生的依赖变动如图2

附加信息:
升级前package.json

{  
  "dependencies": {  
    "@dcloudio/uni-app": "3.0.0-3090920231225001",  
    "@dcloudio/uni-app-plus": "3.0.0-3090920231225001",  
    "@dcloudio/uni-components": "3.0.0-3090920231225001",  
    "@dcloudio/uni-h5": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-alipay": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-baidu": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-jd": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-kuaishou": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-lark": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-qq": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-toutiao": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-weixin": "3.0.0-3090920231225001",  
    "@dcloudio/uni-mp-xhs": "3.0.0-3090920231225001",  
    "@dcloudio/uni-quickapp-webview": "3.0.0-3090920231225001",  
    "clipboard": "^2.0.11",  
    "crypto-js": "^4.2.0",  
    "dayjs": "^1.11.10",  
    "long": "^5.2.3",  
    "pinia": "2.0.36",  
    "uview-plus": "^3.1.45",  
    "vue": "3.2.47",  
    "vue-i18n": "9.6.2"  
  },  
  "devDependencies": {  
    "@dcloudio/types": "3.4.1",  
    "@dcloudio/uni-automator": "3.0.0-3090920231225001",  
    "@dcloudio/uni-cli-shared": "3.0.0-3090920231225001",  
    "@dcloudio/uni-stacktracey": "3.0.0-3090920231225001",  
    "@dcloudio/vite-plugin-uni": "3.0.0-3090920231225001",  
    "@iconify-json/carbon": "^1.1.30",  
    "@uni-helper/eslint-config": "^0.0.6",  
    "@uni-helper/uni-app-types": "^0.5.12",  
    "@uni-helper/uni-cloud-types": "^0.5.2",  
    "@uni-helper/unocss-preset-uni": "^0.2.7",  
    "@uni-helper/vite-plugin-uni-pages": "^0.2.14",  
    "@vue/runtime-core": "3.3.7",  
    "eslint": "^8.57.0",  
    "mini-types": "^0.1.7",  
    "miniprogram-api-typings": "^3.12.2",  
    "sass": "1.64.2",  
    "unocss": "^0.58.5",  
    "unplugin-auto-import": "^0.17.5",  
    "vite": "4.0.3",  
    "vite-plugin-inspect": "^0.8.3",  
    "vite-plugin-remove-console": "^2.2.0"  
  }  
}

升级后package.json

  "dependencies": {  
    "@dcloudio/uni-app": "3.0.0-4000620240325001",  
    "@dcloudio/uni-app-plus": "3.0.0-4000620240325001",  
    "@dcloudio/uni-components": "3.0.0-4000620240325001",  
    "@dcloudio/uni-h5": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-alipay": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-baidu": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-jd": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-kuaishou": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-lark": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-qq": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-toutiao": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-weixin": "3.0.0-4000620240325001",  
    "@dcloudio/uni-mp-xhs": "3.0.0-4000620240325001",  
    "@dcloudio/uni-quickapp-webview": "3.0.0-4000620240325001",  
    "clipboard": "^2.0.11",  
    "crypto-js": "^4.2.0",  
    "dayjs": "^1.11.10",  
    "long": "^5.2.3",  
    "pinia": "2.0.36",  
    "uview-plus": "^3.1.45",  
    "vue": "3.2.47",  
    "vue-i18n": "9.6.2"  
  },  
  "devDependencies": {  
    "@dcloudio/types": "3.4.1",  
    "@dcloudio/uni-automator": "3.0.0-4000620240325001",  
    "@dcloudio/uni-cli-shared": "3.0.0-4000620240325001",  
    "@dcloudio/uni-stacktracey": "3.0.0-4000620240325001",  
    "@dcloudio/vite-plugin-uni": "3.0.0-4000620240325001",  
    "@iconify-json/carbon": "^1.1.30",  
    "@uni-helper/eslint-config": "^0.0.6",  
    "@uni-helper/uni-app-types": "^0.5.12",  
    "@uni-helper/uni-cloud-types": "^0.5.2",  
    "@uni-helper/unocss-preset-uni": "^0.2.7",  
    "@uni-helper/vite-plugin-uni-pages": "^0.2.14",  
    "@vue/runtime-core": "3.3.7",  
    "eslint": "^8.57.0",  
    "mini-types": "^0.1.7",  
    "miniprogram-api-typings": "^3.12.2",  
    "sass": "1.64.2",  
    "unocss": "^0.58.5",  
    "unplugin-auto-import": "^0.17.5",  
    "vite": "4.0.3",  
    "vite-plugin-inspect": "^0.8.3",  
    "vite-plugin-remove-console": "^2.2.0"  
  }  
}
2024-03-26 14:10 负责人:无 分享
已邀请:
cczzz

cczzz (作者)

查看vite的仓库,_getUnresolvedUrlToModule 提交于 https://github.com/vitejs/vite/commit/c268cfaf0fdb0c82db22fcc67b790c00b2c248ac , 对应tag如下:

$  git describe --tags c268cfaf0fdb0c82db22fcc67b790c00b2c248ac  
v4.3.0-beta.1-14-gc268cfaf0

我的项目vite版本是4.03,升级到4.5.3后就没问题了。 @dcloudio/uvm能否也将vite的版本纳入管理范围

要回复问题请先登录注册