Cannot read property 'modules' of undefined

vue3+vite更新版本后报错:Cannot read property 'modules' of undefined

 

 

安装新依赖之后重新运行项目,发现页面打不开,控制台报错如上,首先看到Error出现在App.vue中,但是没装依赖之前项目是正常运行的,通过卸载依赖、重装依赖、页面清空等操作发现项目都跑不起来。遂去Vite的issue中查找,发现了这条:TypeError: ssrContext is undefined · Issue #6043 · vitejs/vite (github.com)

I had tried to replicate your issue without succes. is correct should not happen in spa app.
vite 2.7 requires vue plugin version 1.10 and up \

意思是Vite 2.7以上的版本需要vue plugin高于1.10

解决方案:

  • 手动更改@vitejs/plugin-vue的版本 高于1.10,或者删掉对应包管理工具的.lock文件
  • 重装依赖,重启项目
posted @ 2022-03-24 14:57  Peter_Yang0942  阅读(1357)  评论(0编辑  收藏  举报