简体   繁体   English

'eslint'无法使用文件名

[英]'eslint' is not working with the file name

I have tried using 'eslint' is not recognized as an internal or external command 我尝试使用'eslint'识别为内部或外部命令

And have successfully created .eslintrc.json 并已成功创建.eslintrc.json

and the output of file is 并且文件的输出是

{ "extends": "google" }

But while running cmd eslint app.js , it is giving me an error 但是在运行cmd eslint app.js ,它给了我一个错误

'eslint' is not recognized as an internal or external command, operable program or batch file

Also I tried running command "./node_modules/.bin/eslint app.js" in the folder but it is giving me error "'.' is not recognized as an internal or external command, operable program or batch file" 我也尝试在文件夹中运行命令"./node_modules/.bin/eslint app.js" ,但它给我错误"'.' is not recognized as an internal or external command, operable program or batch file" "'.' is not recognized as an internal or external command, operable program or batch file"

System Info PC: WINDOWS 系统信息PC:WINDOWS

How to resolve this? 如何解决呢?

my eslintrc file is just 我的eslintrc文件只是

.eslintrc 

without the .json 没有.json

env = vs code with eslint rc installed globally env = vs全局安装了eslint rc的代码

I got the solution, but don't know why this happens to me. 我找到了解决方案,但是不知道为什么会这样。

Solution: 解:

I added the script in package.json 我在package.json添加了脚本

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "set DEBUG=* & node app.js",
    "lint": "./node_modules/.bin/eslint app.js"
 }

and run command npm run lint in terminal and it start working . 然后在终端中运行命令npm run lint ,它开始工作

Hope it will work for others also, who get the same error 希望它也适用于其他人,同样的错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM