【问题标题】:'eslint' is not working with the file name'eslint' 不适用于文件名
【发布时间】:2018-07-29 13:45:39
【问题描述】:

我尝试过使用 'eslint' is not recognized as an internal or external command

并且已经成功创建.eslintrc.json

文件的输出是

{ "extends": "google" }

但是在运行 cmd 时 eslint app.js,它给了我一个错误

'eslint' 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"

系统信息 电脑:WINDOWS

如何解决这个问题?

【问题讨论】:

  • 是的,但我尝试了针对该问题给出的解决方案,但它仍然不适合我@melpomene
  • 你是如何安装eslint的?它是在您的package.json 中还是您使用npm install -g eslint 全局安装?
  • 我在全球安装了它以及node node_modules\eslint\bin\eslint.js --init@btmills

标签: javascript node.js npm eslint


【解决方案1】:

我得到了解决方案,但不知道为什么会发生这种情况。

解决方案:

我在package.json

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

并在终端中运行命令npm run lint,它开始工作

希望它也适用于遇到同样错误的其他人

【讨论】:

  • 解决了问题,因为我添加了脚本:{ "lint": "./node_modules/.bin/eslint app.js" }
  • npm run lint 可能,但eslint
【解决方案2】:

我的 eslintrc 文件只是

.eslintrc 

没有 .json

env = vs 全局安装 eslint rc 的代码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-17
    • 2019-10-26
    • 2015-12-01
    • 2021-03-21
    • 2020-04-06
    • 2015-03-15
    • 1970-01-01
    • 2020-02-13
    相关资源
    最近更新 更多