1***@qq.com
1***@qq.com
  • 发布:2024-12-06 17:27
  • 更新:2024-12-09 14:11
  • 阅读:119

Vue3+vite+uniapp,运行不起来

分类:uni-app

这个项目是上个同事搭建的,离职后没有留下任何交接文档,请问这中项目结构怎么运行?是需要在vscode下运行还是Hbuilder下运行?也不能打包成app,打包也会出错,(本人已经1年多没接触过uniapp,之前运用的基本都忘记了,百度了很久也解决不了),希望各位大佬们能帮忙看看!!!非常感激!!! 下面附带了项目结构截图
第一张图片是项目结构截图
第二张是uniapp运行报错信息
后面的是package.json截图****

在vscode下运行指令:npm run dev:app 会报错
错误信息:
PS F:\workspace\aolong-eip-classcard> npm run dev:app
Debugger attached.

uni-preset-vue@0.0.0 dev:app
uni -p app

Debugger attached.
请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。
编译器版本:4.08(vue3)
正在编译中...
failed to load config from F:\workspace\aolong-eip-classcard\vite.config.ts
error during build:
Error [ERR_REQUIRE_ESM]: require() of ES Module F:\workspace\aolong-eip-classcard\node_modules\unocss\dist\vite.
Instead change the require of F:\workspace\aolong-eip-classcard\node_modules\unocss\dist\vite.mjs to a dynamic i in all CommonJS modules.
es/vite/dist/node/chunks/dep-934dbc7c.js:64314:28)
at async resolveConfig (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:63922:28)
at async Module.build (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:46282:20)
at async buildApp (F:\workspace\aolong-eip-classcard\node_modules\@dcloudio\vite-plugin-uni\dist\cli\build.js:123:24)
at async CAC.runDev (F:\workspace\aolong-eip-classcard\node_modules\@dcloudio\vite-plugin-uni\dist\cli\action.js:56:30)
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...

在uniapp下运行也会报错:

17:21:15.806 项目 'aolong-eip-classcard' 开始编译...
17:21:18.539 请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。
17:21:18.540 vite是按需编译,运行时点击某个未编译页面会先编译后加载,导致显示较慢,发行后无此问题。
17:21:18.549 编译器版本:4.08(vue3)
17:21:18.553 正在编译中...
17:21:18.842 failed to load config from F:\workspace\aolong-eip-classcard\vite.config.ts
17:21:18.844 error when starting dev server:
17:21:18.848 Error [ERR_REQUIRE_ESM]: require() of ES Module F:\workspace\aolong-eip-classcard\node_modules\unocss\dist\vite.mjs not supported.
17:21:18.852 Instead change the require of F:\workspace\aolong-eip-classcard\node_modules\unocss\dist\vite.mjs to a dynamic import() which is available in all CommonJS modules.
17:21:18.856 at Object.<anonymous> (F:\workspace\aolong-eip-classcard\vite.config.ts:38:28)
17:21:18.856 at _require.extensions.<computed> [as .js] (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:64450:24)
17:21:18.861 at loadConfigFromBundledFile (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:64458:21)
17:21:18.866 at async loadConfigFromFile (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:64314:28)
17:21:18.870 at async resolveConfig (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:63922:28)
17:21:18.870 at async _createServer (file:///F:/workspace/aolong-eip-classcard/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:63206:20)
17:21:18.874 at async createServer (F:\workspace\aolong-eip-classcard\node_modules\@dcloudio\vite-plugin-uni\dist\cli\server.js:44:20)
17:21:18.875 at async CAC.runDev (F:\workspace\aolong-eip-classcard\node_modules\@dcloudio\vite-plugin-uni\dist\cli\action.js:50:28)

2024-12-06 17:27 负责人:无 分享
已邀请:
风之源

风之源 - 我这么闲给你评论,是因为我的问题还没有人回答~

看着不是hbuilder运行的

风之源

风之源 - 我这么闲给你评论,是因为我的问题还没有人回答~

看着不是hbuilder运行的

锦鲤丶接单丶

锦鲤丶接单丶 - 锦鲤丶接单丶18560000860丶10+年开发经验

unocss的版本问题吧

  • 1***@qq.com (作者)

    下载依赖的时候确实提示了unocss的版本错误信息,然后我百度之后把原先的unocss从0.58改成了0.62,把typescript从4.9.4更改成了5.0.0。没更之前依赖下载失败,更改之后依赖才下载好的

    2024-12-09 09:51

  • 1***@qq.com (作者)

    npm ERR! code ERESOLVE

    npm ERR! ERESOLVE unable to resolve dependency tree

    npm ERR!

    npm ERR! While resolving: uni-preset-vue@0.0.0

    npm ERR! Found: unocss@0.58.9

    npm ERR! node_modules/unocss

    npm ERR! dev unocss@"0.58" from the root project

    npm ERR! peer unocss@">=0.58" from @uni-helper/unocss-preset-uni@0.2.10

    npm ERR! node_modules/@uni-helper/unocss-preset-uni

    npm ERR! @uni-helper/unocss-preset-uni@"^0.2.7" from the root project

    npm ERR!

    npm ERR! Could not resolve dependency:

    npm ERR! peer unocss@">=0.62" from unocss-applet@0.8.5

    npm ERR! node_modules/unocss-applet

    npm ERR! peer unocss-applet@">=0.7" from @uni-helper/unocss-preset-uni@0.2.10

    npm ERR! node_modules/@uni-helper/unocss-preset-uni

    npm ERR! @uni-helper/unocss-preset-uni@"^0.2.7" 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 C:\Users\Lenovo\AppData\Local\npm-cache\eresolve-report.txt for a full report.


    npm ERR! A complete log of this run can be found in:

    npm ERR! C:\Users\Lenovo\AppData\Local\npm-cache_logs\2024-12-09T01_58_47_703Z-debug-0.log

    2024-12-09 09:59

锦鲤丶接单丶

锦鲤丶接单丶 - 锦鲤丶接单丶18560000860丶10+年开发经验

npm install --legacy-peer-deps 这样试试

锦鲤丶接单丶

锦鲤丶接单丶 - 锦鲤丶接单丶18560000860丶10+年开发经验

报错日志中提醒了

要回复问题请先登录注册