vue项目启动后,页面全空白,并报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)

问题:

vue项目启动后,页面全空白,并报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘install’)

在这里插入图片描述

解决方案:

原因:vue-router版本不对,将原本的版本卸载后,重新下载
先卸载之前的vue-router:

npm uninstall vue-router

在下载适合vue2版本的:

npm i vue-router@3.5.2

试了试还是不管用 就在网上查到需要后面加上 -legacy-peer-deps 可以绕过peerDependency自动安装,保证各个引入的依赖之间对自身所使用的不同版本modules共存

npm i vue-router@3.5.2 -legacy-peer-deps

执行完毕后,即可正常启动项目。

遇到的问题:

这个错误是在使用npm卸载之前的vue-router时发生的,错误如下:

npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path E:\nodejs\npm_cache_cacache\tmp\7ab9b301
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open ‘E:\nodejs\npm_cache_cacache\tmp\7ab9b301’
npm ERR! [Error: EPERM: operation not permitted, open ‘E:\nodejs\npm_cache_cacache\tmp\7ab9b301’] {
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘open’,
npm ERR! path: ‘E:\nodejs\npm_cache\_cacache\tmp\7ab9b301’
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It’s possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.

原因:是因为 npm_global 和 node_cache 两个文件夹,普通用户没有权限打开,为普通用户赋权即可。
将 npm_global 和 node_cache 两个文件的普通用户权限打开即可解决该问题,操作步骤如下图:

在这里插入图片描述在这里插入图片描述

启动项目后页面空白报错参考链接:https://blog.csdn.net/weixin_43585289/article/details/126738520
使用npm卸载或下载依赖报错参考链接:https://blog.csdn.net/weixin_51281841/article/details/124087948

猜你喜欢

转载自blog.csdn.net/m0_46459413/article/details/127770469