microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.76k stars 337 forks source link

Failed to load eslint library in v8 #1527

Closed jdgamble555 closed 2 years ago

jdgamble555 commented 2 years ago

I CAN get eslint to work in my projects if I run:

npm i -D eslint@7.32.0

However, all of the newest versions of frameworks don't support this version. Angular and Sveltekit, for example, now use the latest version 8.

I am using Windows 11 with Powershell. All of my projects give the same error.

In both my local .vsocde/settings.json and global settings.json file I have this:

    "eslint.alwaysShowStatus": true,
    "eslint.runtime": "",
    "eslint.validate": [
        "vue",
        "html",
        "javascript",
        "typescript",
        "javascriptreact",
        "typescriptreact"
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll": true,
    },
    "eslint.workingDirectories": [
        {
            "mode": "auto"
        }
    ],
    "eslint.useESLintClass": true,
    "eslint.nodePath": "C:\\Users\\jdgam\\AppData\\Roaming\\npm\\node_modules"

I have uninstalled and reinstalled eslint gloabally npm i -g eslint.

No matter what I do, I still get this error even on a brand new clean project.

I have ESLint VS Code Extension v2.2.6 (latest).

eslint error

How can I get version 8 working on my Windows machine?

Thanks,

J

MariaSolOs commented 2 years ago

What happens if you remove the "eslint.nodePath" setting?

dbaeumer commented 2 years ago

Here is a simple playground that uses ESLint >= 8.0. Does that one work for you?

jdgamble555 commented 2 years ago

@MariaSolOs - Nothing. I would think the opposite would be true. Having that set is what should make it work? Correct?

@dbaeumer - No, it does not. The same error. I uninstalled and reinstalled eslint globally.

play1

Here is my whole global settings.json file:

{
    "material-icon-theme.showWelcomeMessage": false,
    "files.autoSave": "afterDelay",
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "[typescript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "typescript.updateImportsOnFileMove.enabled": "always",
    "[svelte]": {
        "editor.defaultFormatter": "svelte.svelte-vscode"
    },
    "[json]": {
        "editor.defaultFormatter": "SimonSiefke.prettier-vscode"
    },
    "[jsonc]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "[scss]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "javascript.updateImportsOnFileMove.enabled": "always",
    "[graphql]": {
        "editor.defaultFormatter": "SimonSiefke.prettier-vscode"
    },
    "wallaby.codeLensFeature.runTest": true,
    "workbench.editor.revealIfOpen": false,
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "svelte.enable-ts-plugin": true,
    "editor.bracketPairColorization.enabled": true,
    "[typescriptreact]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "[css]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    "go.toolsManagement.autoUpdate": true,
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "eslint.alwaysShowStatus": true,
    "eslint.validate": [
        "vue",
        "html",
        "javascript",
        "typescript",
        "javascriptreact",
        "typescriptreact",
        "angular"
    ],
    "editor.codeActionsOnSave": {
        "source.fixAll": true,
    },
    "eslint.workingDirectories": [
        {
            "mode": "auto"
        }
    ],
    "eslint.useESLintClass": true
}

J

MariaSolOs commented 2 years ago

@MariaSolOs Nothing. I would think the opposite would be true. Having that set is what should make it work? Correct?

I might be wrong, but I thought that there was no need to set "eslint.nodePath" when the module is installed globally.

dbaeumer commented 2 years ago

I am sure you did but did you run npm install in that directory before testing it?

Are you using yarn or some other package manager.

And @MariaSolOs is right. there is usually no need to tinker with eslint.nodePath. We get the global installation path by running npm.

dbaeumer commented 2 years ago

One other idea is to clean the node cache. May be the cached npm module is corrupted.

Does eslint work in the terminal for you in that playground by executing ./node_modules/.bin/eslint --version in the playground directory.

MariaSolOs commented 2 years ago

@jdgamble555 Based on how the library is loaded here, I would also suggest removing the "eslint.workingDirectories" setting (together with "eslint.nodePath").

jdgamble555 commented 2 years ago

@dbaeumer - Yes, eslint works fine outside of VS Code. Running the command prints 8.23.1 as espected.

  1. It is not a corrupted node_modues problem, as it effects ALL my packages (whether using vite, sveltekit, angular, etc). I have created new modules etc.
  2. I am using npm with node v16.15.0.
  3. I have tried uninstalling eslint globally and reinstalling it.

I have removed all other settings in my global settings.json file so I have:

{
    "material-icon-theme.showWelcomeMessage": false,
    "files.autoSave": "afterDelay",
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "[typescript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "typescript.updateImportsOnFileMove.enabled": "always",
    "[svelte]": {
        "editor.defaultFormatter": "svelte.svelte-vscode"
    },
    "[json]": {
        "editor.defaultFormatter": "SimonSiefke.prettier-vscode"
    },
    "[jsonc]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "[scss]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "javascript.updateImportsOnFileMove.enabled": "always",
    "[graphql]": {
        "editor.defaultFormatter": "SimonSiefke.prettier-vscode"
    },
    "wallaby.codeLensFeature.runTest": true,
    "workbench.editor.revealIfOpen": false,
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "svelte.enable-ts-plugin": true,
    "editor.bracketPairColorization.enabled": true,
    "[typescriptreact]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "[css]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    "go.toolsManagement.autoUpdate": true,
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "eslint.alwaysShowStatus": true,
    "eslint.validate": [
        "vue",
        "html",
        "javascript",
        "typescript",
        "javascriptreact",
        "typescriptreact"
    ]
}

I believe this is a bug in all versions after v7.32.0, as it works before that version. Has anyone actually gotten v8 to work on Windows 11 with VS Code and the latest version of eslint plugin for VS Code? I have a feeling no one has tested this, hence why it does not work on these setups.

Thanks,

J

dbaeumer commented 2 years ago

Almost all my repositories use ESlint v8, together with the lastest VS Code and ESLint plugin. You might want to clone this one (https://github.com/microsoft/vscode-eslint.git) and do the following:

Please note that this repository uses a locally installed eslint. Try this with an empty global settings file:

image
dbaeumer commented 2 years ago

And here an example with ESLint v8 loaded from a global location.

image
dbaeumer commented 2 years ago

Global eslint version is v8.23.1

jdgamble555 commented 2 years ago

vscode error

It does not load (I'm ignoring the other errors). I tried uninstalling and reinstalling eslint globally with the same result.

J

MariaSolOs commented 2 years ago

@jdgamble555 do you have several versions of node installed in your computer?

jdgamble555 commented 2 years ago

No, I do not.

J

jdgamble555 commented 2 years ago

So I got it working. I uninstalled all of my VS Code extensions and reopened my projects. Everything works now. I do not know which specific plugin caused the issue.

Thank you guys for all of your help!

J