Babel-eslint: Module build failed: TypeError: Cannot read property 'range' of undefined

Created on 10 Apr 2018  路  9Comments  路  Source: babel/babel-eslint

I can't get my project to build. I've been trying different versions of everything and I just can't get this going! Here's my package dependencies:

"dependencies": {
    "@material-ui/icons": "^1.0.0-beta.42",
    "@types/react": "^16.3.6",
    "autoprefixer": "7.1.6",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "classnames": "^2.2.5",
    "cx": "^18.4.1",
    "dotenv": "4.0.0",
    "dotenv-expand": "4.2.0",
    "extract-text-webpack-plugin": "3.0.2",
    "fs-extra": "3.0.1",
    "history": "^4.7.2",
    "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
    "material-ui": "^1.0.0-beta.41",
    "object-assign": "4.1.1",
    "perfect-scrollbar": "^1.3.0",
    "postcss-flexbugs-fixes": "3.2.0",
    "promise": "8.0.1",
    "prop-types": "^15.6.1",
    "raf": "3.4.0",
    "react": "^16.3.1",
    "react-dev-utils": "^5.0.1",
    "react-dom": "^16.3.1",
    "react-localize-redux": "^2.17.3",
    "react-popper": "^0.10.1",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^5.0.0-alpha.9",
    "redux": "^3.7.2",
    "redux-devtools-extension": "^2.13.2",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.9.1",
    "redux-thunk": "^2.2.0",
    "sw-precache-webpack-plugin": "0.11.4",
    "webpack": "3.8.1",
    "webpack-dev-server": "2.9.4",
    "webpack-manifest-plugin": "1.3.2",
    "whatwg-fetch": "2.0.3"
  },
"devDependencies": {
    "@commitlint/cli": "^6.1.3",
    "@commitlint/config-conventional": "^6.1.3",
    "babel-core": "6.26.0",
    "babel-eslint": "^8.2.2",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-plugin-root-import": "^5.1.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-1": "^6.24.1",
    "babel-runtime": "6.26.0",
    "css-loader": "0.28.7",
    "eslint": "^4.19.1",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-flowtype": "2.39.1",
    "eslint-plugin-import": "^2.10.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.7.0",
    "eslint-plugin-testcafe": "^0.2.1",
    "file-loader": "1.1.5",
    "husky": "^0.15.0-rc.13",
    "lint-staged": "^7.0.4",
    "postcss-loader": "2.0.8",
    "resolve": "1.6.0",
    "style-loader": "0.19.0",
    "url-loader": "0.6.2"
  },

And my .babelrc

{
  "sourceMaps": true,
  "comments": false,
  "presets": [
    [
      "env",
      {
        "targets": {
          "browsers": ["last 2 versions", "safari >= 10"]
        },
        "include": [
          "transform-es2015-classes",
          "transform-es2015-destructuring",
          "transform-regenerator"
        ],
        "useBuiltIns": true,
        "production": {
          "plugins": [
            "transform-react-remove-prop-types",
            "transform-decorators-legacy",
            {
              "mode": "remove",
              "ignoreFilenames": ["node_modules"],
              "removeImport": true
            }
          ]
        },
        "modules": false
      }
    ],
    "react",
    "stage-1"
  ],
  "plugins": [
    "transform-runtime",
    "transform-decorators-legacy",
    [
      "babel-plugin-root-import",
      {
        "rootPathSuffix": "src/"
      }
    ]
  ],
  "env": {
    "test": {
      "presets": [
        [
          "env",
          {
            "modules": "commonjs"
          }
        ]
      ],
      "plugins": [
        "transform-class-properties",
        "transform-object-rest-spread"
      ]
    }
  }
}

And finally my .eslintrc

{
  "root": true,
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "node": true,
    "jest": true
  },
  "plugins": ["react"],
  "extends": ["airbnb", "plugin:testcafe/recommended"],
  "rules": {
    "global-require": ["off"],
    "import/extensions": ["off"],
    "import/no-dynamic-require": ["off"],
    "import/no-unresolved": [
      2,
      {
        "ignore": ["~/*"]
      }
    ],
    "import/prefer-default-export": ["warn"],
    "indent": [2],
    "linebreak-style": ["off"],
    "no-param-reassign": ["warn"],
    "object-curly-newline": ["off"],
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [".js", ".jsx"]
      }
    ],
    "react/jsx-indent": ["error", 2]
  },
  "globals": {
    "__DEV__": true
  }
}

Can anyone see what's wrong? Because I've been trying forever...

All 9 comments

i don't have the answer, but also having this issue 馃槥 i've tried many different fixes to no avail

I have the exact same issue, no fix yet.

Turning off indent rule in .eslintrc works. Not ideal, but works.

@Haggus version 8.0.0 seems to work. I think it broke based on a change to @babel/types

Remove "parser": "babel-eslint" the problem goes away.
https://github.com/babel/babel-eslint/issues/530

@edbond88 what if you want to use the babel-eslint parser?

@kaityhallman idk. I have the same problem.

the same, and can not change babel-eslint version because it was installed by react-scripts

Thank you for the issue. Now that @babel/eslint-parser has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.

Was this page helpful?
0 / 5 - 0 ratings