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 启动报错 #571

Closed
kongDespair opened this issue Aug 12, 2021 · 27 comments
Closed

vite 启动报错 #571

kongDespair opened this issue Aug 12, 2021 · 27 comments

Comments

@kongDespair
Copy link

node_modules/vue-cropper/dist/vue-cropper.es.js:1:55: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "createElementBlock"
node_modules/vue-cropper/dist/vue-cropper.es.js:1:99: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "createElementVNode"
node_modules/vue-cropper/dist/vue-cropper.es.js:1:123: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "normalizeStyle"
node_modules/vue-cropper/dist/vue-cropper.es.js:1:178: error: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "normalizeClass"

@xyxiao001
Copy link
Owner

是 vue3 嘛,vue-cropper@next是 vue3 的版本

@thunderstreak
Copy link

我也遇到了同样的问题,这是我package.json
{
"version": "1.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"@vue/cli-service": "^4.5.13",
"ant-design-vue": "^2.2.1",
"axios": "^0.21.1",
"dayjs": "^1.10.6",
"less": "^4.1.1",
"mitt": "^3.0.0",
"qs": "^6.10.1",
"sass": "^1.35.1",
"swiper": "^6.7.5",
"vite-plugin-style-import": "^1.0.1",
"vue": "^3.0.5",
"vue-aliplayer-v2": "^1.3.0",
"vue-cropper": "^1.0.0",
"vue-router": "^4.0.10",
"vuex": "^4.0.2",
"web-downloadfile": "^0.0.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.2.4",
"@vue/compiler-sfc": "^3.0.5",
"lodash-es": "^4.17.21",
"vite": "^2.4.0",
"vite-plugin-vue-svg": "^0.1.0"
}
}

@xyxiao001
Copy link
Owner

image

@xyxiao001
Copy link
Owner

image

@xyxiao001
Copy link
Owner

刚刚 vite 初始化的项目,没有问题

@xyxiao001
Copy link
Owner

image

@kongDespair
Copy link
Author

但我这边的确报错了

@kongDespair
Copy link
Author

是@next的

@xyxiao001
Copy link
Owner

更新下 @vitejs/plugin-vue 试一试

@kongDespair
Copy link
Author

image

@xyxiao001
Copy link
Owner

你怎么引入的

@xyxiao001
Copy link
Owner

image
你应该更新下 @vue/compiler-sfc 和 vue 版本,这应该是一个 bug,已经修复了
vitejs/vite#4573

@kongDespair
Copy link
Author

打包发布就出错
image

@kongDespair
Copy link
Author

本地运行是没有问题的

@xyxiao001
Copy link
Owner

感觉还是 vite 版本的问题,
我刚刚又重新搞了个 vite 的项目
仓库 https://github.com/xyxiao001/cropper-test
编译后 https://github.xyxiao.cn/cropper-test/dist/

@kongDespair
Copy link
Author

image
我的vite版本

@xyxiao001
Copy link
Owner

"@vitejs/plugin-vue": "^1.3.0",
"@vue/compiler-sfc": "^3.0.5",
"vite": "^2.4.4"
这几个依赖改为这样看看

@kongDespair
Copy link
Author

一样的

@kongDespair
Copy link
Author

本来加上^就会更新到最新版

@ubbcou
Copy link

ubbcou commented Aug 19, 2021

这是因为node_modules里面安装了两个不同版本的vue,vue-cropper不应该将vue当成dependencies依赖提交到npm

@xyxiao001
Copy link
Owner

我修改下,对应的依赖我移动处理下

@xyxiao001
Copy link
Owner

1.0.1版本我移动到dependencies了,应该不是 vue 版本的问题,都是向上兼容安装的

@ubbcou
Copy link

ubbcou commented Aug 19, 2021

错误复现:

"dependencies": {
"vue": "^3.0.5",
"vue-cropper": "^1.0.0",
}
// yarn.lock
// 此时lock文件部分内容
vue@^3.0.5:
  version "3.1.4"
  resolved "https://registry.yarnpkg.com/vue/-/vue-3.1.4.tgz#120d6818c51eaa35d0879e5bc1cff60135bc69fd"
  integrity sha512-p8dcdyeCgmaAiZsbLyDkmOLcFGZb/jEVdCLW65V68LRCXTNX8jKsgah2F7OZ/v/Ai2V0Fb1MNO0vz/GFqsPVMA==
  dependencies:
    "@vue/compiler-dom" "3.1.4"
    "@vue/runtime-dom" "3.1.4"
    "@vue/shared" "3.1.4"

这个情况下安装vue-cropper@1.0.0,因为项目与vue-cropper一样都是用了vue@^3.0.5,此时vue-copper使用同一个vue依赖(3.1.4)报错。

然后更新 lock 文件:yarn upgrade vue

// yarn.lock
vue@^3.0.5:
  version "3.2.4"
  resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.4.tgz#d94d88675e41c050d3a722d0848a7063b5e87a60"
  integrity sha512-rNCFmoewm8IwmTK0nj3ysKq53iRpNEFKoBJ4inar6tIh7Oj7juubS39RI8UI+VE7x+Cs2z6PBsadtZu7z2qppg==
  dependencies:
    "@vue/compiler-dom" "3.2.4"
    "@vue/runtime-dom" "3.2.4"
    "@vue/shared" "3.2.4"

错误解决。

当然,vue-copper移动依赖是最合理的解决方式

@ubbcou
Copy link

ubbcou commented Aug 19, 2021

安装vue-copper@^1.0.1后,vue版本还是得更新的,只不过vue-copper不再会产生单独的vue版本依赖了

@xyxiao001
Copy link
Owner

了解,我当时处理时,没有移动依赖到 dependencies

@kongDespair
Copy link
Author

解决了

@Yill625
Copy link

Yill625 commented Dec 21, 2021

一样的错误 还是不知道怎么解决

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

5 participants