pnpm: eslint can't find plugins when run from pnpm binstubs

I’m trying to use eslint plugins (e.g. eslint-plugin-jest) with pnpm and WebStorm. eslint works fine from the command line and can use the plugins, but when Webstorm runs the eslint binstub, it fails with

Failed to load plugin jest: Cannot find module ‘eslint-plugin-jest’

Since this seemed like a WebStorm issue, I’ve filed https://youtrack.jetbrains.com/issue/WEB-36548. WebStorm developers replied there, saying it might be a pnpm issue. @zkochan, can you please take a look?

The issue is rather critical because it essentially makes it impossible to use eslint with pnpm in WebStorm (since most projects use an eslint plugin or config).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Well, this feature will be better if integrated into pnpm. I was working on it a few weeks ago. I guess I can try to finish it. https://github.com/pnpm/pnpm/commit/f1fdcd1c2787d29982795a90ea0c0c75d65d8806

I can reproduce the problem without WebStorm. When calling node_modules/eslint/bin/eslint.js *.js from the a directory, eslint can’t find the plugin:

$ git clone git@github.com:dandv/webstorm-pnpm-eslint-jest.git
Cloning into 'webstorm-pnpm-eslint-jest'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (13/13), done.
Receiving objects: 100% (19/19), 36.86 KiB | 1.02 MiB/s, done.
Resolving deltas: 100% (4/4), done.
remote: Total 19 (delta 4), reused 17 (delta 2), pack-reused 0
~/prg$ cd webstorm-pnpm-eslint-jest
~/prg/webstorm-pnpm-eslint-jest$ pnpm multi install
Scope: all 2 workspace packages
Performing headless installation
.                                        | +522 ++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 522, reused 503, downloaded 19, done
node_modules/.registry.npmjs.org/fsevents/1.2.4/node_modules/fsevents: Running install script, done in 55ms
~/prg/webstorm-pnpm-eslint-jest$ cd a
~/prg/webstorm-pnpm-eslint-jest/a$ node_modules/eslint/bin/eslint.js *.js

Oops! Something went wrong! :(

ESLint: 5.11.1.
ESLint couldn't find the plugin "eslint-plugin-jest". This can happen for a couple different reasons:

1. If ESLint is installed globally, [...]

2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm i eslint-plugin-jest@latest --save-dev

Path to ESLint package: /home/dandv/prg/webstorm-pnpm-eslint-jest/node_modules/.registry.npmjs.org/eslint/5.11.1/node_modules/eslint

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

pnpm 2.25.2.

Hahaha oh well then yes it works, because I’m using that now.