Vue 保存文件vite.config.ts 出现下面报错。Replace ⏎↹createViteProxy,⏎↹getRootPath,⏎↹getSrcPath,⏎↹setupVitePlugins,⏎↹viteDefine,⏎}·from·"./build" with ·createViteProxy,·getRootPath,·getSrcPath,·setupVitePlugins,·viteDefine·}·from·'./build'eslintprettier/prettier
网上找了下原因说是我的VSCode配置和项目的.eslint.rc或.prettier.rc冲突了,项目的.eslint.rc
修复方法,在项目根目录增加.vscode/settings.json文件,
{
/**
*This setting instructs VSCode to automatically apply all available code fixes *when you save a file. Code fixes can include actions such as formatting code *to match a defined style guide, fixing syntax errors, removing unused imports, *etc. By setting `"source.fixAll": true`, you're enabling VSCode to *automatically apply all available fixes to your code when you save the file.
*/
// 自动修复代码 包括格式化 修复语法错误 去掉没用到的导入
"editor.codeActionsOnSave": { "source.fixAll": true },
// 不会自动格式化代码 这样就不会和项目的格式配置冲突
"editor.formatOnSave": false,
}
然后去报错的文件 重新保存 正常了
全局修复方法
"lint-fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx,json,css,scss,md}'",
npm run lint-fix
参考链接
stackoverflow.com/questions/6…