【发布时间】:2018-06-29 19:33:00
【问题描述】:
每当我尝试通过
安装 eslint-config-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。
我不知道我哪里出错了。
相关问题:另外,我的~(home) 文件夹中有一个全局默认.eslintrc 文件,我从Atom 中的linter - eslint 包中指向该文件。当我在 Atom 上保存任何 .js 文件时,我得到 p>
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,
}
}
【问题讨论】:
-
eslint 可执行文件的 Atom 设置是什么?您可以尝试将其直接指向您的模块文件夹,例如 ~/node_modules/eslint/bin
-
@Papasmile 我的 .eslintrc 路径设置为
~/.eslintrc.js我的文件实际所在的位置。任何项目读取或访问该文件都没有问题。只是检测不到eslint-config-google。 -
啊,知道了。我认为 atom 不使用全局插件,请参阅 github.com/AtomLinter/linter-eslint/issues/110
-
@Papasmile 确实如此,伙计。请查看我的回答。
-
只是说如果“使用全局”被关闭,它认为你已经安装了一个本地包,并且你已经使用 $PATH 将全局安装的包添加到你的运行时,所以它看起来像一个本地文件.. .. 无论如何,这一切有点傻,所以 +1 将您的经验发布到 github.com/AtomLinter/linter-eslint/issues/603 这可能是找出根本原因的好地方:)
标签: javascript atom-editor eslint linter eslintrc