1. 程式人生 > 其它 >react構建專案後start失敗:Error while loading rule 'jsx-a11y/alt-text'

react構建專案後start失敗:Error while loading rule 'jsx-a11y/alt-text'

今天學了一天react,構建過很多次專案,結果晚上六點多用creat-react-app 建立的專案卻無法start了,提示如下:

對比了一下 各個檔案,應該是package-lock.json檔案裡的版本什麼的有變化了。
然後找這個jsx-a11y有什麼變化,發現版本變了
將配置從

"eslint-plugin-jsx-a11y": {
    "version": "6.5.0",
    "resolved": "http://registry.npm.baidu-int.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.5.0.tgz",
    "integrity": "sha1-KRaAgxzvYKy85Rq4Hmbbygsqs9Q=",
    "requires": {
    "@babel/runtime": "^7.16.3",
    "aria-query": "^4.2.2",
    "array-includes": "^3.1.4",
    "ast-types-flow": "^0.0.7",
    "axe-core": "^4.3.5",
    "axobject-query": "^2.2.0",
    "damerau-levenshtein": "^1.0.7",
    "emoji-regex": "^9.2.2",
    "has": "^1.0.3",
    "jsx-ast-utils": "^3.2.1",
    "language-tags": "^1.0.5",
    "minimatch": "^3.0.4"
},

改為

"eslint-plugin-jsx-a11y": {
    "version": "6.4.1",
    "resolved": "http://registry.npm.baidu-int.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.4.1.tgz",
    "integrity": "sha1-othMqkl1aUL0Lx/6uQAkNjkXGP0=",
    "requires": {
    "@babel/runtime": "^7.11.2",
    "aria-query": "^4.2.2",
    "array-includes": "^3.1.1",
    "ast-types-flow": "^0.0.7",
    "axe-core": "^4.0.2",
    "axobject-query": "^2.2.0",
    "damerau-levenshtein": "^1.0.6",
    "emoji-regex": "^9.0.0",
    "has": "^1.0.3",
    "jsx-ast-utils": "^3.1.0",
    "language-tags": "^1.0.5"
},

再重新 npm install 一下,就又能成功start了