Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[coc.nvim] Failed to load the ESLint library for the document test.js #11

Closed
kevindashgit opened this issue Apr 26, 2019 · 22 comments
Closed

Comments

@kevindashgit
Copy link

I'm just now getting more "serious" about using Coc in my development machine - and I'm trying to use this extension as a replacement for ALE by suggestion from this article but unfortunately I'm getting some pretty buggy behavior.

When I load a javascript file (any file) I see warnings that are legit warnings (like the neovim "sign" / gutter indicator is there) but I see the error in this issue summary at the bottom
image

However, if I play around enough (not sure what triggers it, but spamming $ and 0 in normal mode on a line where a sign exists eventually triggers the expected warning (and btw this one in particular I'd love to turn off but I realize its an existing annoyance for others):
image

I did try `:CocUpdateSync and got this output:

:!yarnpkg upgrade --latest --ignore-engines
[No write since last change]

yarn upgrade v1.13.0
warning package.json: No license field
warning No license field
warning No license field
warning No license field
[1/4] Resolving packages...
warning coc-prettier > prettier-eslint > eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
warning coc-prettier > prettier-stylelint > stylelint > autoprefixer > browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "coc-prettier > prettier-tslint@0.4.2" has unmet peer dependency "typescript@^2.5.3 || ^3.0.0".
warning "coc-prettier > prettier-tslint > tslint@5.16.0" has unmet peer dependency "typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev
|| >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev".
warning "coc-prettier > prettier-tslint > tslint > tsutils@2.29.0" has unmet peer dependency "typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=
2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev".
[4/4] Rebuilding all packages...
success Saved lockfile.
warning No license field
success Saved 365 new dependencies.

Is that warning anything special?

I'd greatly appreciate any help here :)

:CocInfo Output

## versions

vim version: NVIM v0.3.2-dev
node version: v10.15.3
coc.nvim version: 0.0.65-5effa64974
term: iTerm.app
platform: darwin

## Error messages

## Output channel: prettier


[Trace - 4/26/2019, 1:34:45 PM:] Formatted file: file:///Users/foobar/temp/test.js


[Trace - 4/26/2019, 1:34:45 PM:] Prettier format edits: [
  {
    "range": {
      "start": {
        "character": 0,
        "line": 0
      },
      "end": {
        "character": 0,
        "line": 16
      }
    },
    "newText": "var debug = require(\"debug\");\n\n// A comment\n\nfunction sayHi() {\n  console.log(\"hi\");\n}\n\naksayHi();\n\nasdfl;\nj: w;\n"
  }
]


## Output channel: tsserver

[Info  - 1:34:32 PM] Forking TSServer
PATH: /Users/foobar/.yarn/bin:/Users/foobar/.config/yarn/global/node_modules/.bin:/var/folders/nl/ry78xgy13djdd9ntz2vfkq240000gn/T/fnm-shell-299137/bin:/Users/foobar/.fnm:/opt/local/bin:/opt/local/sbin:/Users/foobar/.pyenv/plugins/pyenv-virtualenv/shims:/Users/foobar/.pyenv/shims:/Users/foobar/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/Users/foobar/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Users/foobar/.yarn/bin:/Users/foobar/.config/yarn/global/node_modules/.bin:/var/folders/nl/ry78xgy13djdd9ntz2vfkq240000gn/T/fnm-shell-3942512/bin:/Users/foobar/.fnm:/opt/local/bin:/opt/local/sbin:/Users/foobar/.pyenv/plugins/pyenv-virtualenv/shims:/Users/foobar/.pyenv/shims:/Users/foobar/.pyenv/bin:/Users/foobar/.cargo/bin 
[Info  - 1:34:32 PM] Started TSServer
{
  "path": "/Users/foobar/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib",
  "_pathLabel": "",
  "_api": {
    "versionString": "3.3.4000",
    "version": "3.3.4000"
  }
}

## Output channel: eslint

[Info  - 1:34:32 PM] ESLint server running in node v10.15.3

:CocConfig

{
  "suggest.echodocSupport": true,
  "suggest.maxCompleteItemCount": 20,
  "coc.preferences.formatOnSaveFiletypes": ["javascript", "typescript", "typescriptreact", "json", "javascriptreact"],
  "eslint.filetypes": ["javascript", "typescript", "typescriptreact", "javascriptreact"],
  "eslint.options": {
    "configFile": "~/.eslintrc"
  },
  "diagnostic.errorSign": "",
  "diagnostic.warningSign": "",
  "diagnostic.infoSign": ""
}
@chemzqm
Copy link
Member

chemzqm commented Apr 27, 2019

Make sure eslint can be resolve from your workspaceFolder https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders or global npm modules.

You can disable suggest actions from tsserver https://github.com/neoclide/coc-tsserver#configuration-options.

@chemzqm chemzqm closed this as completed Apr 27, 2019
@VVoruganti
Copy link

I am having the same issue no matter where I open a script file.

Not sure how to see if eslint can resolve.

@chemzqm
Copy link
Member

chemzqm commented May 10, 2019

Checkout your npm global module folder by npm root -g and make sure your have eslint inside that folder.

@kevindashgit
Copy link
Author

@chemzqm you've spotted a recurring issue with my regular workflow - which is that I regularly switch node versions via nvm and so some versions I've properly installed eslint while others not so much. 🎆 👍

Bonus Points: I'd still prefer not to have to move cursor over "underlined" section to see the warning as reflected by the vim "sign" (marker indicating an issue on this line. Is there a setting to reveal the issue just by moving cursor to the erroneous line?

@chemzqm
Copy link
Member

chemzqm commented May 11, 2019

@kevindashgit Then you need to specify eslint.nodePath

@dzintars
Copy link

Same issue when opening Yarn 2 Berry PnP project.

@fannheyward
Copy link
Member

@dzintars When using coc-eslint with yarn2 project, follow this:

  1. yarn add @yarnpkg/pnpify add to your project
  2. yarn pnpify --sdk

Now coc-eslint will find eslint automatically.

@dzintars
Copy link

@fannheyward Tnx. I already did that, but no luck. Will update this issue when will get into something. BTW... which is recommended method today to install plugins? :CocInstall coc-eslint or Plug 'neoclide/coc-eslint', {'do': 'yarn install --frozen-lockfile'}?

@fannheyward
Copy link
Member

:CocInstall coc-eslint, extensions installed with :CocInstall can do auto-updating.

@stiofand
Copy link

stiofand commented Apr 25, 2020

I have had the same issue with eslint without success, I am unable to get coc working with either eslint or prettier, sadly I have to revert to another method until there is a solution for this.

@emmtte
Copy link

emmtte commented May 11, 2020

Same issue for me with coc-prettier and coc-eslint
After manually install dependencies on dev folder work like as expected
npm install --save-dev eslint prettier eslint-config-prettier eslint-plugin-prettier
(Node.js 14)

@lauri-codes
Copy link

I'm also experiencing the same issue. After installing with :CocInstall coc-eslint, I have eslint installed under the path reported by npm root -g. I only got eslint working after installing it locally for the project as suggested by @emmtte using the command npm install --save-dev eslint. My setup is:

  • coc-eslint 1.2.7
  • coc.nvim version: 0.0.78-42353685a1
  • vim version: NVIM v0.4.3
  • node version: v12.16.3

@arbitrary-dev
Copy link

For me the problem was that I've installed eslint using Yarn, and so I have to set:

"eslint.nodePath": "/home/user/.config/yarn/global/node_modules"

@ghost
Copy link

ghost commented Oct 3, 2020

@chemzqm

Can I skip the error?

If I have a random js file somewhere not in project, then this error always happens.

I think this is supposed to be, but I want to skip the error if there is no eslint configuration.

@chemzqm
Copy link
Member

chemzqm commented Oct 3, 2020

You can create .vim/coc-setings.json at any parent folder of your file.

@ghost
Copy link

ghost commented Oct 3, 2020

Oh.... I see.
So I need to create config file everytime I open random js file.

Um well, it can't be helped.
thanks

@chemzqm
Copy link
Member

chemzqm commented Oct 3, 2020

Or you can create a global eslint config file.

@ghost
Copy link

ghost commented Oct 3, 2020

@chemzqm
I tried that!
In that case even if I'm in some project, coc will look to global eslint.

prettierrc.js behavior is good.
https://prettier.io/docs/en/configuration.html

The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn’t) found.

@chemzqm
Copy link
Member

chemzqm commented Oct 3, 2020

You can use "root": true to make eslint not look up.

@ghost
Copy link

ghost commented Oct 3, 2020

@chemzqm
Ah, thank you for reply, but no, in that case if there's no config in that workspace it causes the error,,,,,

(It would be great if this error goes to CocInfoLog. Not error in status line. But as you stated there is an way to handle this, so it's not critical. This is still great plugin.)

@Clev7
Copy link

Clev7 commented Oct 29, 2020

Checkout your npm global module folder by npm root -g and make sure your have eslint inside that folder.

This worked wonders! cd into that folder and do sudo npm install -g eslint and eslint should be where it needs to be

@lambdaFun94
Copy link

Checkout your npm global module folder by npm root -g and make sure your have eslint inside that folder.

This worked wonders! cd into that folder and do sudo npm install -g eslint and eslint should be where it needs to be

Super helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests