最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Babel ES-Lint parse errors in imported module. Cannot find module '.parse-with-patch' - Stack Overf

programmeradmin3浏览0评论

I have been searching Github and Stack Overflow for the past hour with no answer on how to fix this problem with ES-Lint.

.eslintrc.json

{
  "parser": "babel-eslint",
  "extends": ["airbnb", "prettier"],
  "plugins": ["prettier", "flowtype"],
  "rules": {
    "prettier/prettier": ["error"],
    "no-unused-expressions": 0,
    "react/jsx-filename-extension": 0,
    "class-methods-use-this": 0,
    "default-case": 0,
    "import/no-unresolved": 0,
    "react/prefer-stateless-function": 0,
    "import/no-named-as-default": 0
  },
  "parserOptions": {
    "sourceType": "module",
    "import/extensions": [".jsx", ".js"],
    "allowImportExportEverywhere": true
  }
}

devDependencies

"devDependencies": {
    "@babel/plugin-transform-runtime": "^7.1.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.7.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-plugin-flowtype": "^2.34.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-prettier": "^3.0.0",
    "eslint-plugin-react": "^7.11.1",
    "flow-bin": "0.78.0",
    "jest": "23.5.0",
    "jest-react-native": "18.0.0",
    "metro-react-native-babel-preset": "^0.45.0",
    "prettier": "1.14.1",
    "react-native-debugger-open": "0.3.17",
    "react-test-renderer": "16.0.0-alpha.12",
    "schedule": "0.4.0",
    "semver": "5.5.0"
  },

All of the linter options are working which is great, but there is no way I can let other people use this config if I am getting errors for every single import statement throughout the entire app.

Does anyone have any idea what could be going on?

I have been searching Github and Stack Overflow for the past hour with no answer on how to fix this problem with ES-Lint.

.eslintrc.json

{
  "parser": "babel-eslint",
  "extends": ["airbnb", "prettier"],
  "plugins": ["prettier", "flowtype"],
  "rules": {
    "prettier/prettier": ["error"],
    "no-unused-expressions": 0,
    "react/jsx-filename-extension": 0,
    "class-methods-use-this": 0,
    "default-case": 0,
    "import/no-unresolved": 0,
    "react/prefer-stateless-function": 0,
    "import/no-named-as-default": 0
  },
  "parserOptions": {
    "sourceType": "module",
    "import/extensions": [".jsx", ".js"],
    "allowImportExportEverywhere": true
  }
}

devDependencies

"devDependencies": {
    "@babel/plugin-transform-runtime": "^7.1.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.7.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-plugin-flowtype": "^2.34.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-prettier": "^3.0.0",
    "eslint-plugin-react": "^7.11.1",
    "flow-bin": "0.78.0",
    "jest": "23.5.0",
    "jest-react-native": "18.0.0",
    "metro-react-native-babel-preset": "^0.45.0",
    "prettier": "1.14.1",
    "react-native-debugger-open": "0.3.17",
    "react-test-renderer": "16.0.0-alpha.12",
    "schedule": "0.4.0",
    "semver": "5.5.0"
  },

All of the linter options are working which is great, but there is no way I can let other people use this config if I am getting errors for every single import statement throughout the entire app.

Does anyone have any idea what could be going on?

Share Improve this question edited Oct 19, 2018 at 14:51 Dan Zuzevich asked Oct 19, 2018 at 14:36 Dan ZuzevichDan Zuzevich 3,8314 gold badges30 silver badges43 bronze badges 6
  • Seeing same. Started happening after some updates today. It was either the update to Node 11 or just the general dependency updates. It isn't all of my imports, only the ones where I am importing a default export. – Mac Commented Oct 31, 2018 at 1:02
  • Are you using vs code? – Dan Zuzevich Commented Oct 31, 2018 at 1:05
  • No, IntelliJ. It might be Node. I'm not getting the error on TravisCI, which is still using Node 10. – Mac Commented Oct 31, 2018 at 19:07
  • I eliminated the Node version as the culprit. It looks like there might be some inpatibility with Babel 7.1. I had various other (serious) problems until I reverted my dependencies and got back to Babel 7.0. This ESLint issue also seems to be fixed now. – Mac Commented Oct 31, 2018 at 22:18
  • I fixed mine but I honestly dont remember what I did. Did you check to see if you had eslint installed in your global npm dependencies? It might be trying to use that version. I honestly don't remember what fixed my problem. – Dan Zuzevich Commented Oct 31, 2018 at 22:21
 |  Show 1 more ment

6 Answers 6

Reset to default 7

These steps might work:

  1. Change path to path.ts
  2. Save
  3. Again, change it to path
  4. Save

Just disable that rule to rrsolve this issue insted of uninstalling ESLint

"Unfortunately, React + Redux is the most mon scenario. However, there are lots of other cases where HOCs will force developers to shut down this rule."

https://github./benmosher/eslint-plugin-import/issues/544

https://github./reactjs/react-redux/issues/119

https://github./18F/calc/pull/1235

.eslintrc

"rules": {
    "import/no-named-as-default": 0
}

Deleting node_modules and reinstalling everything worked for me :-(

just add in your eslint rules. Works fine for me

"parser": "off",

babel-eslint has been deprecated. Update to @babel/eslint-parser.

https://tjaddison./blog/2021/03/updating-babel-eslint-to-babeleslint-parser-for-react-apps/

Uninstalling EsLint globally fixed my problem: npm uninstall -g eslint

发布评论

评论列表(0)

  1. 暂无评论