espree: strange parsing errors since 4.1.0

eslint depends on espree@^4.0.0, which pulls in 4.1.0 on a fresh install. since installing this version, we’ve been getting strange Parsing errors on perfectly normal JSX syntax, e.g. in this build https://circleci.com/gh/Financial-Times/x-dash/1197. the referenced lines aren’t anything weird. our .eslintrc.js includes a few plugins, including eslint-plugin-react, but is otherwise quite minimal.

when running npm install, i did note that it output:

npm ERR! peer dep missing: acorn@^6.0.0, required by acorn-jsx@5.0.0

even though espree includes acorn@^6.0.0 in its dependencies. seems like this might be a cause, if it’s using an incompatible version of acorn from somewhere?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

No. We are awaiting. This is npm’s bug and the npm CLI team has a plan to fix the bug by Summer in 2019.

Any news on this?

No.

I don’t think the revert makes sense. This causes by acorn’s breaking change. Currently, the npm’s bug appears when there is a older acorn in another dependency. After reverting, it will appear when there is a newer acorn in another dependency. https://github.com/eslint/eslint/issues/11018#issuecomment-438737502

Well when I tried in an empty directory and did what you just did, I no longer saw the error. So I suspect that the issue here is something to do with the specific structure of node_modules I have, which (abbreviated) is:

node_modules
    acorn (@5.7.3) (no deps)
    acorn-jsx (@5.0.0) (peer dependency on acorn@^6.0.0)
    eslint-visitor-keys (@1.0.0) (no deps)
    espree (@4.1.0) (depends on acorn@^6.0.2, acorn-jsx@^5.0.0, eslint-visitor-keys@^1.0.0)
        node_modules
            acorn (@6.0.2) (no deps)

Like .@quarterto I also see npm WARN acorn-jsx@5.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself in my npm install output. So I think this may not a problem with espree specifically. Apologies.

Edit: acorn-jsx@5.7.3 is used by webpack@4 among other things, which explains its presence here.

As a workaround I’ve found that explicitly adding

    "acorn": "^6.0.2",
    "acorn-jsx": "^5.0.0",
    "espree": "^4.1.0",

to my package.json’s devDependencies forces all three packages to be installed at the top level of node_modules, where they can find one another.