代码之家  ›  专栏  ›  技术社区  ›  Aakash Verma

eslint config google未检测到全局安装的eslint

  •  4
  • Aakash Verma  · 技术社区  · 7 年前

    每当我尝试安装 eslint配置google 全球地 通过

    npm install -g eslint-config-google

    我明白了

    npm WARN eslint-config-google@0.9.1 requires a peer of eslint@>=4.1.1 but none is installed.
    You must install peer dependencies yourself.
    

    但当我这样做的时候 eslint --v 我只是想再确认一下 v4.16.0 .

    我不知道我错在哪里。


    从属问题 :此外,我还有一个全局默认值 .eslintrc my中的文件 ~ (主)我从中指向的文件夹 linter - eslint 在Atom中打包。当我保存任何时。Atom上的js文件,我得到

    Cannot find module 'eslint-config-google' Referenced from: /Users/aakashverma/.eslintrc.js

    这是我的 .eslintrc.js 文件位于 ~ :

    module.exports = {
      "extends": ["eslint:recommended", "google"],
      "rules": {
        "indent": [
          "error",
          4
        ],
        "linebreak-style": [
          "error",
          "unix"
        ],
        "quotes": [
          "error",
          "single"
        ],
        "semi": [
          "error",
          "always"
        ],
        // allow console and debugger in development
        'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
        'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
      }
    }
    

    This kind of talks about it.

    1 回复  |  直到 6 年前
        1
  •  1
  •   Aakash Verma    7 年前

    好的,我不确定这是否是缓存问题或其他问题,但我不认为是因为我一直在重新启动Atom和zsh,但它是如何工作的:

    在Atom中,我改变了 .eslintrc Path ~/.eslintrc.js Use global ESlint installation 至“已检查”。

    这是我的 .eslintrc 在Atom中指向的主文件夹中

    enter image description here

    最后,让它与 使用全局ESlint安装 打开后,我将两者都包括在内 eslint-config-google eslint 在我的 $PATH 以这种方式变量

    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /Users/aakashverma/.nvm/versions/node/v9.4.0/lib/node_modules/eslint/
    /Users/aakashverma/.nvm/versions/node/v9.4.0/lib/node_modules/eslint-config-google/
    

    参考@ginna的答案 here 以及我的评论 here .