在安装vue-cli-plugin-element时,按以下指令安装中会让用户选择相应选项
vue add element
在第二个选项我选择了yes, 报错Error: command failed: npm install --loglevel error vue-cli-plugin-element,查找了资料发现第二项选择错误了。vue安装element报错Error: command failed: npm install --loglevel error vue-cli-plugin-element - DrinkOolongTea - 博客园 (cnblogs.com)
于是想要卸载重新安装element-ui,但是在安装时会报错,卸载时也会报错,删除项目重新做还是在安装时报错,重安后报错为
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 ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator
尝试了用管理员身份运行cmd执行安装卸载指令但是没有解决错误,执行npm cache verify同样无法解决此问题。Npm请以root /管理员身份再次尝试使用此命令 (qastack.cn)
有一种方法说解决的问题可以删除C:\Users\{当前登录的用户名}\.npmrc,但是我看了这个文件的修改日期与我安装element-ui的时间不符,在C:\Users\{当前登录的用户名}我发现另一个和npm相关的文件夹为npminstall_tarball我将此文件夹内容全部删除,随后执行element-ui卸载安装指令,均成功执行。