首先更新element-ui
1.先卸载element-ui
使用命令:npm uninstall element-ui 或cnpm uninstall element-ui
2.再次安装element-ui
使用命令:npm install element-ui -S 或 cnpm install element-ui -S
//安装最新版本的element-ui
如果安装指定版本的element-ui,则是
命令: npm install element-ui @2.12.0 -S 或 npm install element-ui
@2.12.0 -S
遇见第一个问题:‘[email protected]’ is not in the npm registry.
npm ERR! 404 'nini-react' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/apple/.npm/_logs/2018-02-04T00_32_35_475Z-debug.log
appledeMacBook-Pro:nini-react apple$
提示[email protected]不在npm注册表中
错误的原因很有可能是npm使用默认的源下载安装包,而默认的安装源是国外网站,国内访问不了无法获取依赖包信息。
这时只需要更换为国内的安装源即可,可在命令行更换为国内淘宝的源:
# 查看自己的安装源
npm config get registry
# 更换npm源为国内淘宝镜像
npm config set registry http://registry.npm.taobao.org/
# 或者更换为国内npm官方镜像
npm config set registry http://registry.cnpmjs.org/
# 还原npm源
npm config set registry https://registry.npmjs.org/
然后遇到了第二个问题:code ETARGET,安装依赖报错安装不上,找不到对应的版本
npm ERR! code ETARGET
npm ERR! notarget No matching version found for es-abstract@1.14.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
于是进入https://www.npmjs.com/ 在里面输入[email protected],发现找不到,输入es-abstract能找到1.19版本,于是在package-lock.json文件中 把es-abstract版本改为1.19
接下来执行更新操作npm install element-ui -S时出现最后一个问题,A complete log of this run can be found in
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-03-14T09_22_30_937Z-debug.log
改用cnpm install element-ui -S 成功解决了该问题