Syntax Error: Error: No ESLint configuration found in /status/Git/mib/src.
Posted 水香木鱼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Syntax Error: Error: No ESLint configuration found in /status/Git/mib/src.相关的知识,希望对你有一定的参考价值。
今天接受了一个 Vue 项目,在执行 npm run serve
命令运行项目时报错:
Error: No ESLint configuration found.
解决方法:
安装 ESlint 并初始化配置:
方法一:
全局安装 ESLint :
npm i eslint -g
生成配置文件:
eslint --init
根据自己的项目需求进行设置:
√ How would you like to use ESLint? · problems √ What type of modules does your project use? · esm √ Which framework does your project use? · vue √ Does your project use TypeScript? · No / Yes √ Where does your code run? · browser √ What format do you want your config file to be in? · javascript The config that you've selected requires the following dependencies: [email protected]/* */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-yjshash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-yjsemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* */ ? Would you like to install them now with npm? » Yes
方法二:
在项目中安装 ESLint :
npm install eslint --save-dev
生成配置文件:
./node_modules/.bin/eslint --init
初始化成功后,会在项目根目录生成一个 .eslintrc.js
文件,文件内容:
module.exports = { "env": { "browser": true, "es2021": true }, "extends": [ "eslint:recommended", "plugin:vue/essential" ], "parserOptions": { "ecmaVersion": 12, "sourceType": "module" }, "plugins": [ "vue" ], "rules": { } };
这里我还遇到一个问题,运行时报错:
Syntax Error: Error: D:\\vue\\rcyj-settle-web\\.eslintrc.js:
Environment key "es2021" is unknown
at Array.forEach ()
这是因为 eslint-plugin-standard
版本不兼容。
解决方法:
将 eslint-config-standard
版本进行降级为 ^14.1.1
:
npm i [email protected]/* */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-yjshash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-yjsemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* */ eslint-plugin-standard -D --save
然后删除 .eslintrc.js
里面 "env"
中的 "es2021"
属性即可。
-----------------------------------------------------------------------------------------------
解决 eslint 的 Parsing error: Unexpected token 错误
问题描述:import动态导入,将js文件单独打包时,webpack打包错误
ERROR in ./src/js/main.js
Module Error (from ./node_modules/_eslint-loader@4.0.2@eslint-loader/dist/cjs.js
):
F:\\workspace\\javascript workspace\\webpack\\prj18_3\\src\\js\\main.js
8:7 error Parsing error: Unexpected token (
✖ 1 problem (1 error, 0 warnings)
问题分析:禁用eslint,webpack打包正常,Parsing error 是eslint解析错误。
解决方案:
1.eslint 配置 babel-eslint 插件
cnpm install babel-eslint --save
2.在package.json中配置 eslintConfig 属性
"eslintConfig": {
"parser": "babel-eslint"
}
以上是关于Syntax Error: Error: No ESLint configuration found in /status/Git/mib/src.的主要内容,如果未能解决你的问题,请参考以下文章
syntax error, error in :'e id=1?', expect QUES, actual QUES pos 66, line 1, column 66, token
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
Parse error: syntax error, unexpected '<' in E:\PHP\showwo8\www\lib\u
SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb4_unicode_ci' is no
Linux 报错:syntax error "C" 解决办法(此处选择bash系统)
mysql 数据库导入数据错误 #1064 - You have an error in your SQL syntax; check the manual