Babel ES-Lint parse errors in imported module. Cannot find module './parse-with-patch'

13,656

Solution 1

These steps might work:

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

Solution 2

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

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

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

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

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

.eslintrc

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

Solution 3

Deleting node_modules and reinstalling everything worked for me :-(

Share:
13,656
Dan Zuzevich
Author by

Dan Zuzevich

I love writing code, and will not stop until I am fluent in many different languages. Just kidding, I am never going to stop.

Updated on June 17, 2022

Comments

  • Dan Zuzevich
    Dan Zuzevich almost 2 years

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

    enter image description here

    .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?

  • Dan Zuzevich
    Dan Zuzevich over 5 years
    Yeah, I think that should solve the problem for most people. Also, a really annoying gotcha is that I had to close and reopen VSCode before the settings took effect. Might be worthwhile for people to remove es lint globally then close and reopen their editor just in case.
  • Alex Varghese
    Alex Varghese about 4 years
    Uninstalling EsLint is not a good practice. ESLint is used for ensuring code quality in the application. Uninstalling that not making any sense
  • Dan Zuzevich
    Dan Zuzevich almost 3 years
    Think people misunderstood this. I believe Alex meant uninstall the global version of eslint, and use the local version declared in the package.json.
  • Aishwarya
    Aishwarya over 2 years
    Please add explanation with/or screen-capture or code. Sharing link over question may invalid after period of time, which tends to invalid answer.