Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)

 启动项目时出现这个错误,检查了下是自己的vue-router安装的版本错误,我写的项目是vue2,vue-router安装的是4.x版本(这是vue3的),版本过高需要卸载重装。

执行npm uninstall vue-router,报错如下:

 这是卸载命令出错,需要这么书写:npm uninstall vue-router --legacy-peer-deps,就卸载成功了。

 接着安装vue2对应的3.x版本的vue-router版本号:

 npm install --save vue-router@3

 错误解决,启动项目就成功了~

猜你喜欢

转载自blog.csdn.net/cxl1191628698/article/details/127352186
今日推荐