[英]Install ESLint + babel-eslint parser globally on Windows 10
我嘗試安裝以 babel-eslint 作為解析器全局運行的 ESLint,但沒有成功。 我在 Windows 10 機器上全局安裝了這兩個軟件包:
npm list --depth=0 -g
C:\Users\UserName\AppData\Roaming\npm
+-- @angular/cli@8.3.9
+-- babel-eslint@10.1.0
+-- create-react-app@3.4.1
+-- eslint@7.10.0
+-- nodemon@2.0.5
+-- npm@6.14.7
+-- npm-check-updates@3.1.23
+-- npm-install-peers@1.2.1
`-- typescript@3.6.4
我的主目錄中存在默認的.eslintrc
配置文件: C:\\Users\\UserName
這工作正常,直到我將babel-eslint
指定為parser
:
{
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"parser": "babel-eslint",
"rules": {
"no-var": "error",
"no-use-before-define": "off",
"no-unused-vars": "warn",
"prefer-const": "warn",
"no-console": "off",
"func-names": "off",
"node/no-unsupported-features/es-syntax": "off"
}
}
ESLint 服務器拋出:
[信息 - 11:06:04] 無法加載在“PersonalConfig”中聲明的解析器“babel-eslint”:找不到模塊“babel-eslint”需要堆棧:-C:\\Users\\UserName\\.eslintrc
順便說一下,只要我嘗試使用 air-bnb 配置擴展我的配置,它也會發生同樣的情況,該配置也是全局安裝的。 我如何告訴 ESLint 在哪里查找依賴項,因為它們沒有安裝在C:\\Users\\UserName
而是安裝在C:\\Users\\UserName\\AppData\\Roaming\\npm
?
嘗試這個:
"parser": "C:/Users/<username>/AppData/Roaming/npm/node_modules/babel-eslint",
不是一個完美的解決方案,但它有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.