Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Cannot find module espree.cjs #15343

Closed
1 task
kaihendry opened this issue Nov 23, 2021 · 5 comments
Closed
1 task

Bug: Cannot find module espree.cjs #15343

kaihendry opened this issue Nov 23, 2021 · 5 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed
Projects

Comments

@kaihendry
Copy link

Environment

Node version: v16.11.1
npm version: npm@8.1.3
Local ESLint version: v7.32.0
Global ESLint version:
Operating System: MacOS 12.0.1 (21A559)


Oops! Something went wrong! :(

ESLint: 8.3.0

Error: An error occurred while generating your JavaScript config file. A config file was still generated, but the config file itself may not follow your linting rules.
Error: Cannot find module '/tmp/check2/node_modules/espree/dist/espree.cjs'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:960:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:953:15)
    at resolveExports (node:internal/modules/cjs/loader:482:14)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (/tmp/check2/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/tmp/check2/node_modules/eslint/lib/rules/utils/ast-utils.js:13:16)
    at Module._compile (/tmp/check2/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)

What parser are you using?

Default (Espree)

What did you do?

  1. npm init -y
  2. npm install eslint --save-dev
$ npx eslint --init
✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · commonjs
✔ Which framework does your project use? · none
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · node
✔ How would you like to define a style for your project? · guide
✔ Which style guide do you want to follow? · standard
✔ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-standard@latest
The config that you've selected requires the following dependencies:

eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1 || ^5.0.0
✔ Would you like to install them now with npm? · No / Yes
Installing eslint-config-standard@latest, eslint@^7.12.1, eslint-plugin-import@^2.22.1, eslint-plugin-node@^11.1.0, eslint-plugin-promise@^4.2.1 || ^5.0.0

added 88 packages, changed 12 packages, and audited 177 packages in 3s

48 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Oops! Something went wrong! :(

What did you expect to happen?

Initialised

What actually happened?

Failed ...

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@kaihendry kaihendry added bug ESLint is working incorrectly repro:needed labels Nov 23, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Nov 23, 2021
@nzakas
Copy link
Member

nzakas commented Nov 25, 2021

I think this is happening because eslint-config-standard hasn’t been upgraded to support ESLint 8.

@aladdin-add what do you think?

@nzakas nzakas moved this from Needs Triage to Feedback Needed in Triage Nov 25, 2021
@aladdin-add
Copy link
Member

aladdin-add commented Nov 25, 2021

mixed things: it's because the "ecmaVersion: 13" was generated via eslint v8, while eslint v7 does not support ecma 13.(eslint v7 was reinstalled aseslint-config-standard does not support eslint v8 yet).

to fix the error, you can change ecmaVersion: 13 => ecmaVersion: 12 in the generated config. it will be fixed in the new @eslint/create-config by setting ecmaVersion: "latest".

@aladdin-add
Copy link
Member

Duplicate of #15159

@aladdin-add aladdin-add marked this as a duplicate of #15159 Nov 25, 2021
Triage automation moved this from Feedback Needed to Complete Nov 25, 2021
@fabiopagoti
Copy link

I have something to add

After installing v8.3 explicitly
npm install --save-dev eslint@8.3.0

and then running
node_modules\.bin\eslint --init


√ How would you like to use ESLint? · style       
√ What type of modules does your project use? · esm
√ Which framework does your project use? · none
√ Does your project use TypeScript? · No / Yes
√ Where does your code run? · browser
√ How would you like to define a style for your project? · guide
√ Which style guide do you want to follow? · standard
√ What format do you want your config file to be in? · JavaScript

Then, I was prompted to install some additional modules

The config that you've selected requires the following dependencies:

eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1 || ^5.0.0
√ Would you like to install them now with npm? · No / Yes (Yes was selected)

Apart from the error mentioned above, I noticed that the devDependencies inside package.json was automattically changed to version 7.

As a workaround, I manually adjusted eslint version in package.json and then repeated the init wizard without downloading those modules again. Like this, the file was generated successfully.

@mdjermanovic
Copy link
Member

This is most likely caused by overwriting ESLint with another version while eslint --init is still running, and will be fixed by extracting eslint --init into a separate package (#14768).

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators May 25, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

5 participants