Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite-ts 模板:dev:mp-weixin 编译时报错 ERROR: Expected ">" but found "setup" 且无法热更新 #102

Open
DengSihan opened this issue Jul 24, 2024 · 9 comments

Comments

@DengSihan
Copy link

issue:

  1. dev:mp-wieixn 编译错误
  2. dev:mp-wieixn 无法实现在微信开发者工具中热更新

reproduction:

  1. npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
  2. cd my-vue3-project && npm run install
  3. npm run dev:mp-weixin
  4. 修改 src/pages/index/index.vue 的任意内容

[plugin:commonjs] Transform failed with 1 error:
PROJECT_DIR/src/App.vue?vue&type=script&setup=true&lang.ts:1:8: ERROR: Expected ">" but found "setup"
at App.vue:1:8

Expected ">" but found "setup"
1 | <script setup lang="ts">
| ^
2 | import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
3 | onLaunch(() => {

ENV:node v20.12.0 win10


在修改了 src/pages/index/index.vue 中的内容后,dist/dev/mp-weixin 中的对应内容并没有更新

@Inori-Lover
Copy link

太奇怪了…两天前的我都没问题的,今天就出现同样报错……

@Inori-Lover
Copy link

Inori-Lover commented Jul 24, 2024

yarn

{ "resolutions": { "@dcloudio/vite-plugin-uni/@vitejs/plugin-vue": "~5.0.4" }}

锁定 @vitejs/plugin-vue 为5.0.x 可解,应该是break了什么东西

再进一步看了下,应该是 5.1 更新了依赖的上游导致的,具体是vite还是rollup…不想继续挖了

pnpm也有覆盖版本的语法,去找找文档就好

@fangyuchuang
Copy link

请问解决这个问题了吗?怎么解决,今天使用npx degit dcloudio/uni-preset-vue#vite-ts 一直报这个错误,使用的是pnpm工具,不知道怎么解决

@DengSihan
Copy link
Author

@Inori-Lover 感谢!很棒的解决方法,使我的代码运行

@fangyuchuang 如果你用的 yarn,按照 @Inori-Lover 的解决办法即可

如果使用的是 npm/pnpm

{
  "overrides": {
    "@dcloudio/vite-plugin-uni": {
      "@vitejs/plugin-vue": "~5.0.4"
    }
  }
}

文档 👉 npm overrides

@fangyuchuang
Copy link

fangyuchuang commented Jul 25, 2024

@DengSihan 你好,在package.json 中添加了
"overrides": {
"@dcloudio/vite-plugin-uni": {
"@vitejs/plugin-vue": "~5.0.4"
}
}
但是依旧是报这个错误,
image

image

依照前面 Inori-Lover 的方法,使用yarn是可以的,不再纠结这个问题了,多谢!

@dmwin72015
Copy link

@DengSihan 你好,在package.json 中添加了 "overrides": { "@dcloudio/vite-plugin-uni": { "@vitejs/plugin-vue": "~5.0.4" } } 但是依旧是报这个错误, image

image

依照前面 Inori-Lover 的方法,使用yarn是可以的,不再纠结这个问题了,多谢!

你是不是使用的pnpm 啊,如果是的话,得用

  "pnpm": {
    "overrides": {
      "@dcloudio/vite-plugin-uni>@vitejs/plugin-vue": "~5.0.4"
    }
  }

@Inori-Lover
Copy link

@DengSihan 这个issue不应该关闭~
overrides/resolutions 只是缓解,建议re-open,让 uni 的开发人员知晓相关情况并发布兼容版本

@DengSihan DengSihan reopened this Jul 26, 2024
@fxy060608
Copy link
Collaborator

dcloudio/uni-app#5061

@sxzz
Copy link

sxzz commented Jul 27, 2024

Should be fixed in v5.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants