0

I am instaling eslint into a new empty folder and I received this message:

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.

I am following this steps:

  1. npm init -y
  2. npm i -D eslint
  3. npx eslint --init

eslint options

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 'C:\Users\vgva\Desktop\Nueva carpeta\para-pruebas-git\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 (C:\Users\vgva\Desktop\Nueva carpeta\para-pruebas-git\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\bgva\Desktop\Nueva carpeta\para-pruebas-git\node_modules\eslint\lib\rules\utils\ast-utils.js:13:16)
    at Module._compile (C:\Users\vgva\Desktop\Nueva carpeta\para-pruebas-git\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)

File package.json:

{
  "name": "para-pruebas-git",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "eslint": "^7.32.0",
    "eslint-config-standard": "^16.0.3",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^5.1.1",
    "eslint-plugin-react": "^7.27.0"
  }
}

File .eslintrc.js

module.exports = {
    "env": {
        "browser": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "plugin:react/recommended",
        "standard"
    ],
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 13,
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
    }
};

What is that error about and why? How to fix it?

Byron2017
  • 871
  • 2
  • 11
  • 23

2 Answers2

1

I have faced the same problem. First I thought Spree might have broken the Semver principle, and I might need to somehow force an older version; but since that path was hacky IMO I decided to first try Yarn with the whole process, just to test my luck, and it worked!

  1. remove node_modules dir
  2. yarn
  3. yarn eslint --init

and it just worked as expected.

Dariush Alipour
  • 318
  • 3
  • 11
0

Just make sure you have the correct node.js version.

Note that eslint only works with ^12.22.0, ^14.17.0, or >=16.0.0

After node.js is updated, run npm install again.

Walty Yeung
  • 3,396
  • 32
  • 33