Vscode-eslint: Failed to load the ESLint library for the document when eslint is installed by yarn

Created on 26 Dec 2017  ยท  12Comments  ยท  Source: microsoft/vscode-eslint

I'm seeing Failed to load the ESLint library for the document when eslint is installed by yarn. I have configured the following -

๐Ÿ $ yarn global add eslint
yarn global v1.1.0
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
warning Pattern ["eslint@^4.14.0"] is trying to unpack in the same destination "/Users/junger/Library/Caches/Yarn/v1/npm-eslint-4.14.0-96609768d1dd23304faba2d94b7fefe5a5447a82" as pattern ["eslint@^4.0.0"]. This could result in a non deterministic behavior, skipping.
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Installed "[email protected]" with binaries:
      - eslint
โœจ  Done in 2.59s.
~/.config/yarn/global
๐Ÿฏ $ ls -la /usr/local/bin/eslint
lrwxr-xr-x  1 junger  admin  75 Dec 19 15:29 /usr/local/bin/eslint -> ../../../Users/junger/.config/yarn/global/node_modules/eslint/bin/eslint.js
~/.config/yarn/global

To find the node path I did -

๐Ÿฎ $ which node
/Users/junger/.nvm/versions/node/v8.9.3/bin/node

And then in settings.json set the following

"eslint.nodePath": "/Users/junger/.nvm/versions/node/v8.9.3/bin/node",

Then I receive this error message -

[Info  - 06:27:58] 
Failed to load the ESLint library for the document /Users/junger/dev/stanley/shedview/configurator/src/middleware/analytics-middleware.js

To use ESLint please install eslint by running 'npm install eslint' in the workspace folder stanley
or globally using 'npm install -g eslint'. You need to reopen the workspace after installing eslint.

Alternatively you can disable ESLint for the workspace folder stanley by executing the 'Disable ESLint' command.

Is yarn installation of eslint supported?

*out-of-scope feature-request help wanted

Most helpful comment

Argh looks like this setting fixed it -

"eslint.packageManager": "yarn",

Maybe it could just autodetect / try both?

All 12 comments

Argh looks like this setting fixed it -

"eslint.packageManager": "yarn",

Maybe it could just autodetect / try both?

This is only a problem if yarn is used to install eslint globally. If installed locally it works regardless whether yarn or npm is used.

I will close the issue since most of the time eslint is installed locally. Please ping if you disagree.

@dbaeumer Do you have usage data that backs this up? And would you accept a PR to fix? For companies that have a lot of projects it is more consistent and dry'r to install eslint globally. Usually eslint is a standard across all the projects in a company or organization within a company.

We always try hard to avoid global dependencies and from all the issue I got so far most people install eslint locally to their project. The only thing they might have outside of the project is a global eslint configuration file. PRs are always welcome. I will reopen the issue.

Yeah same here. ๐Ÿ‘

@dbaeumer how about just a documentation hint in the error message? That'd be a good start. I can make the change if you want.

Tweaking the error message is definitely a first good step.

Since installing eslint globally is a valid option, it would make sense to automatically look for both npm and yarn global installs, and thus do away with the need for users to fiddle with settings.

@dbaeumer can you approve my PR?

Done. I am very busy with work in VS Code itself. So sorry for the delay.

Keeping the issue open for the PR to auto detect this.

This feature request will not be considered in the next 6-12 months and has been closed to keep the number of issues we have to maintain manageable. See also our issue reporting guidelines.

Thanks for your understanding and happy coding!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaelig picture kaelig  ยท  5Comments

ablakey picture ablakey  ยท  5Comments

NickHeiner picture NickHeiner  ยท  4Comments

bacsonvv picture bacsonvv  ยท  6Comments

sebastian-nowak picture sebastian-nowak  ยท  4Comments