uni-app使用uni-starter模版启动报错
uni-app使用uni-starter模版启动报错
操作步骤:
- 新建项目->unicloud -> uni-starter模版 vue3 ->运行小程序模拟器->小红书
预期结果:
- 能正常启动
实际结果:
- 10:51:42.022 [vite]: Rollup failed to resolve import “vue” from “D:/WorkSpaces/HBuilderProjects/ds-shop/main.js”.
- This is most likely unintended because it can break your application at runtime.
- If you do want to externalize this module explicitly add it to
build.rollupOptions.external
bug描述:
- 10:51:42.022 [vite]: Rollup failed to resolve import “vue” from “D:/WorkSpaces/HBuilderProjects/ds-shop/main.js”.
- This is most likely unintended because it can break your application at runtime.
- If you do want to externalize this module explicitly add it to
build.rollupOptions.external
更多关于uni-app使用uni-starter模版启动报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
uni-starter 小程序端仅测试了微信,其他平台需要自己调试
更多关于uni-app使用uni-starter模版启动报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这个错误是因为Vite构建时无法解析vue依赖。在uni-starter模板中,可以尝试以下解决方案:
- 确保项目依赖已正确安装:
npm install
- 检查项目根目录下vite.config.js文件,确保vue已被正确配置。可以尝试添加:
optimizeDeps: {
include: ['vue']
}
-
如果使用HBuilderX创建项目,建议使用内置的npm管理器安装依赖,而不是手动执行npm install。
-
检查项目package.json中vue的版本是否与uni-app兼容,建议使用3.x版本。
-
清理项目缓存后重新运行:
rm -rf node_modules && npm install