vscode-eslint: [2.1.13] Suddenly not resolving modules anymore on working projects

For some reason the eslint extension cannot find/resolve NONE of the modules anymore on a working project that was finding everything before without issue. It looks like this is a change in the extension I don’t know about or an issue.

At first when I saw this I thought I needed to upgrade the eslint package, so I’m at the latest version of eslint now, but without success.

Looking in the Output panel though I see this a weird error thrown by the extension (by eslintServer.js):

Error resolving webpackConfig Error: Cannot find module 'webpack/package.json'

Which makes sense that it cannot find it as my package.json is in the root of the project, as normal, but shouldn’t look there in the first place. Not sure why it’s searching in some webpack folder the project doesn’t even have, but it’s obvious that it cannot find it there.

The ESLint label in the bottomright corner is marked with a double checkbox, so it’s not blocked or whatever.

[edit] I see that at least v2.1.10, v2.1.8 and v2.1.7, so the previous three versions, have the exact same issue and same error message in the output. But I didn’t change anything AFAIK to both the project as well as to the installed modules. I’m at the latest version of VS Code for a while now (1.51.1) and didn’t have this problem recently. Also just checked for updates on VS Code but there weren’t any. This was definitely working last week and didn’t change anything manually since, so beats me what’s going on.

It’s now suddenly broken in ALL projects, so definitely not project-related. I’m using the locally installed eslint package on each project.

Something I need to know? Some change in the settings maybe I’m not aware of? Do we need to manually set the location of the package.json now or something? Is this a known issue in the extension?

Further info:

  • Working on Windows 10
  • Vs Code: v1.51.1
  • eslint: v7.15.0 (installed locally in project, no global package available)
  • eslint-plugin-import: v2.22.1
  • eslint-import-resolver-webpack: v0.12.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

The working directory setting you use is basically a noop since using the workspace root is the default.

Why then did you give this advise in the first place? Come on man, read my posts before advising.

Since ESLint depends on so many parameters (version, plugins, configuration files, package.json entries, and eventually webpack configuration and TS configuration files) debugging this does from my experience require an example. Otherwise it is very unlikely that we ever talk about the same setup.

A good developer knows what questions to ask. Requesting a full project from a user to debug an issue in your own extension is pretty lame to me.

Also I already gave you the version numbers in my opening post.

Several times I now asked you to ask questions so I can help you, but you refuse to ask these questions. You obviously don’t want to help. I quit helping you debugging the issues in your extension now. You obviously don’t want to fix this nor recognise this issue. This is the last post I posted about this as you’re wasting my time.

I am happy to hear that you could solve the issue.

Alright. The issue didn’t have anything to do with Eslint, nor everything related.

There is an issue in the latest version of the svg-sprite-loader node package; it’s trying to execute some internal code to require ‘webpack/package.json’, but can’t find it and so throws an error causing the full vscode-eslint process to stop by this error. Changing the webpackVersion constant in that module by hand now fixes the issue.

Just found out there are more people with the same issue here: JetBrains/svg-sprite-loader#417

Not sure why vscode-eslint is more sensitive to this than direct command line eslint though, as that wasn’t showing any error nor stopped the process, but at least found the issue now finally.

Sorry for all the inconvience. Closing this issue now.

You are my hero! Thanks!

Alright. The issue didn’t have anything to do with Eslint, nor everything related.

There is an issue in the latest version of the svg-sprite-loader node package; it’s trying to execute some internal code to require ‘webpack/package.json’, but can’t find it and so throws an error causing the full vscode-eslint process to stop by this error. Changing the webpackVersion constant in that module by hand now fixes the issue.

Just found out there are more people with the same issue here: https://github.com/JetBrains/svg-sprite-loader/issues/417

Not sure why vscode-eslint is more sensitive to this than direct command line eslint though, as that wasn’t showing any error nor stopped the process, but at least found the issue now finally.

Sorry for all the inconvience. Closing this issue now.

@mvirbicianskas thanks for jumping in. You are correct I don’t need the full repository, a distilled version is enough which I tried to point out in this comment https://github.com/microsoft/vscode-eslint/issues/1136#issuecomment-744681195 via

could you distil a reproducible case.

This is also documented in our issue guidlines: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions#writing-good-bug-reports-and-feature-requests

@Friksel ESlint and most of its plugins and configurations resolve files relative to a current working directory. So if ESLint can’t find certain files than in many cases the current working directory is not correct. The setting I pointed you too gives you control over the working directory the eslint server is using when validating certain files.