Closed kongDespair closed 3 years ago
是 vue3 嘛,vue-cropper@next是 vue3 的版本
我也遇到了同样的问题,这是我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" } }
刚刚 vite 初始化的项目,没有问题
但我这边的确报错了
是@next的
更新下 @vitejs/plugin-vue 试一试
你怎么引入的
你应该更新下 @vue/compiler-sfc 和 vue 版本,这应该是一个 bug,已经修复了 https://github.com/vitejs/vite/issues/4573
打包发布就出错
本地运行是没有问题的
感觉还是 vite 版本的问题, 我刚刚又重新搞了个 vite 的项目 仓库 https://github.com/xyxiao001/cropper-test 编译后 https://github.xyxiao.cn/cropper-test/dist/
我的vite版本
"@vitejs/plugin-vue": "^1.3.0", "@vue/compiler-sfc": "^3.0.5", "vite": "^2.4.4" 这几个依赖改为这样看看
一样的
本来加上^就会更新到最新版
这是因为node_modules
里面安装了两个不同版本的vue,vue-cropper不应该将vue当成dependencies依赖提交到npm
我修改下,对应的依赖我移动处理下
1.0.1版本我移动到dependencies了,应该不是 vue 版本的问题,都是向上兼容安装的
错误复现:
"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移动依赖是最合理的解决方式
安装vue-copper@^1.0.1
后,vue
版本还是得更新的,只不过vue-copper
不再会产生单独的vue
版本依赖了
了解,我当时处理时,没有移动依赖到 dependencies
解决了
一样的错误 还是不知道怎么解决
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"