The ScenarioYou open a project and realize your code looks suspiciously clean. No red squiggles appear, and the usual linting warnings are nowhere to be found. When you check the Output panel (selecting 'ESLint' from the dropdown), you see the culprit:
Failed to load plugin. Cannot find module 'eslint'
This error typically triggers when the ESLint extension cannot locate the eslint package. While the command might work in your terminal, the VS Code extension often struggles to find the binary in your node_modules or global environment. It leaves your editor blind to style violations even though your build scripts run perfectly.
Why This Error OccursVS Code's ESLint extension does not always share the same environment as your terminal. Your shell uses the system PATH, but the extension specifically hunts for a local installation at your workspace root. If you are working in a monorepo, forgot to run npm install, or recently switched Node versions via NVM, the extension loses the trail.
Quick Fix: Install ESLint LocallyMost modern projects require ESLint as a local development dependency. Even if you have a global version installed, the VS Code extension prioritizes the local node_modules to ensure version parity across your team. Missing this local package is the cause of roughly 80% of these errors.
Run the appropriate command in your project root:
# For npm users
npm install eslint --save-dev
# For yarn users
yarn add eslint --dev
# For pnpm users
pnpm add -D eslint
Once the 40MB to 50MB of dependencies finish downloading, reload the window. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) and type "Developer: Reload Window" to reset the extension server.
Permanent Fix 1: Configure Monorepo Working DirectoriesStandard settings often fail in monorepos managed by Lerna, Nx, or Turborepo. If your package.json sits in /packages/ui/ but you opened the root folder in VS Code, the extension looks in the wrong place. It expects node_modules at the very top level.
You can fix this by defining your project structure in .vscode/settings.json:
{
"eslint.workingDirectories": [
{ "mode": "auto" }
]
}
If auto mode fails to detect your subfolders, list them explicitly to guide the extension:
{
"eslint.workingDirectories": [
"./apps/web",
"./apps/api",
"./packages/shared"
]
}
Permanent Fix 2: Align the Node PathThe extension might be trying to use a system-default Node version that lacks your project's dependencies. This is common if you use version managers like asdf or nvm. If the extension points to /usr/bin/node but your project needs v18.15.0, it won't find the modules.
Find your active Node path by typing which node (macOS/Linux) or where node (Windows) in your terminal. Then, tell VS Code exactly which executable to use:
{
"eslint.nodePath": "/Users/username/.nvm/versions/node/v18.15.0/bin/node"
}
Note: Hardcoding this path is a last resort. It is usually better to ensure your shell environment is correctly exported to VS Code.
Permanent Fix 3: Launch from the TerminalEnvironment variables can get lost when you launch VS Code from a GUI shortcut or dock. If you use NVM, the shell may not have initialized the Node path before the extension started. This leads to the "module not found" error because the extension is looking in an empty environment.
- Close every instance of VS Code.- Open your terminal and
cdinto your project folder.- Ensure the correct Node version is active (e.g.,nvm use 18).- Typecode .to launch the editor.This method forces VS Code to inherit the environment variables from your active terminal session. It is a highly effective way to resolve path conflicts.
How to Verify the FixConfirm the fix by checking the internal logs rather than just looking for squiggles. Follow these steps:
- Open any
.jsor.tsfile.- Navigate to View > Output.- Select ESLint from the dropdown menu on the right.- Look for the message:ESLint server is running.To test it manually, addconst x = 1;to a file. If you have theno-unused-varsrule active, a yellow warning should appear immediately. This confirms the extension is successfully communicating with the ESLint module.

