ant design pro移除国际化报错解决步骤

发布时间 2023-12-31 14:45:18作者: 犹豫的象

一、环境
ant-design-pro版本:6.0.0
npm 版本:8.1.0
node 版本:v16.13.0
二、开步骤
1、点击移除按钮
image
2、报错误" Failed to load config "prettier" to extend from."
image
3、使用命令"npm i --save-dev prettier eslint-config-prettier eslint-plugin-prettier"(参考github官方issues:https://github.com/ant-design/ant-design-pro/issues/10497)
image
4、使用命令安装包错误,这个错误意味着npm在尝试安装这些包时遇到了依赖冲突。具体来说,eslint-plugin-prettier@5.1.2需要一个prettier版本>=3.0.0,但项目中已安装的prettier版本是2.8.8。由于prettier@3.0.0尚未发布,安装失败。
image
5、改成命令“npm i --save-dev prettier@2.8.8 eslint-config-prettier eslint-plugin-prettier@4.0.0”
image
6、再次执行移除国际化命令,报错误" Environment key "es2022" is unknown"
image
7、issue解决方案:https://github.com/ant-design/ant-design-pro/issues/10452
image
image
8、再次运行移除国际化命令,此时又报错误"Cannot find module 'eslint-plugin-unicorn'"
image
9、issue解决方案:https://github.com/ant-design/ant-design-pro/issues/10452
image
10、此时我们运行命令"npm add eslint-config-prettier --dev yarn add eslint-plugin-unicorn --dev "
image
11、此时我们再次运行移除国际化命令,没有报错,此时运行项目,发现已经没有切换语言的选项了,但是左侧没有目录了。image
12、原来的路由没有name属性所以看不见菜单栏,这里我们使用下面的代码替换路由文件,并且使用admin账号登录。
image

export default [
{ name: '登录', path: '/user', layout: false, routes: [{ path: '/user/login', component: './User/Login' }] },
{ name: '欢迎页面', path: '/welcome', icon: 'smile', component: './Welcome' },
{
path: '/admin',
icon: 'crown',
access: 'canAdmin',
name: '管理员页面',
routes: [
{ path: '/admin', redirect: '/admin/sub-page' },
{ path: '/admin/sub-page', component: './Admin' },
],
},
{ icon: 'table', path: '/list', component: './TableList', name: '表格页' },
{ path: '/', redirect: '/welcome' },
{ path: '*', layout: false, component: './404' },
];
image
13、最后,我们将locals目录删除
image