Giter VIP home page Giter VIP logo

Comments (36)

unional avatar unional commented on August 16, 2024 1

I have a different case but with the same error. By the way I tested my project that is using eslint is it is working for me (I installed it locally).

My case is when opening a project that does not have package.json, eslint not installed, and there are no.eslintrcor.eslintrc.*in the project. In this case thevscode-eslint` should not be activated.

from vscode-eslint.

vxzhong avatar vxzhong commented on August 16, 2024 1

After chsh -s /bin/zsh, reboot the mac osx, then the vscode will detect the default shell to 'zsh', then the global installed 'eslint' will be found.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024 1

The ESLint extension has currently no support for globally install eslint module via yarn. I opened: #187

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

Hmm. this works for me with a locally installed eslint and 0.10.8. See screen shot

capture

@Ciget do you have a NODE_PATH environment variable set. I fixed a bug lately which cause the eslint load fail in case a NODE_PATH environment variable is present.

from vscode-eslint.

adamweeks avatar adamweeks commented on August 16, 2024

@egamma are you using nvm? I'm experiencing this issue as well on my machines that have nvm installed.

from vscode-eslint.

adamweeks avatar adamweeks commented on August 16, 2024

Sorry, looks like the original issue author was @Ciget

from vscode-eslint.

Ciget avatar Ciget commented on August 16, 2024

@dbaeumer, nop, even after remove this variable from env settings and restart - still have this issue.

from vscode-eslint.

ShimShamSam avatar ShimShamSam commented on August 16, 2024

As per my comment on issue #24, removing all globally installed NPM packages and reinstalling them fixed my issue. I'm pretty sure this is related to the latest NPM version using a different folder structure for dependencies, which I recently upgraded to.

from vscode-eslint.

collinforrester avatar collinforrester commented on August 16, 2024

@ShimShamSam Are you on windows? I just tried removing all of my global modules per your solution and it didn't work.

Very well could be because I'm on windows though and have my global modules stored in a non standard location.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

I played a little with this and here are my finds:

  • using nvm together with the eslint extension worked for me.
  • a non standard global modules store worked for me as well

The eslint plugin uses 'npm config get prefix' to find the location of the globally installed modules. @collinforrester does this point to your global store ?

from vscode-eslint.

collinforrester avatar collinforrester commented on August 16, 2024

Yes it does.

I just tried to recreate the issue that I was having and its no longer occurring on this machine. So a combination of ShimShamSam's solution, reboot, vscode, and eslint update.. something seems to have fixed it.

I realize that doesn't help much as far as specifics, but its what worked for me.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@unional agree. Please see: #68

from vscode-eslint.

GeorgeSapkin avatar GeorgeSapkin commented on August 16, 2024

The issue I had when installing ESLint in npm prefix is that the prefix was configured as an environment variable in .bashrc instead of using npm config set prefix. So npm config get prefix returned the correct path even though it was not in npm config get and VS Code couldn't find ESLint. After I removed environment variable and moved prefix to npm config, ESLint was found.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@GeorgeSapkin thanks for the insight. Didn't even know that this is possible.

from vscode-eslint.

novembrea avatar novembrea commented on August 16, 2024

I have the same issue and unfortunately it didn't get resolved via aforementioned solutions. I'm using NVM and ESlint is installed globally. Here are the details:

  • OS: Ubuntu 16.04
  • VSCode: 1.2
  • Node: 6.2.1
  • NPM: 3.9.3
  • ESlint: 2.12.0
which node
>/home/nvma/.nvm/versions/node/v6.2.1/bin/node
which eslint
>/home/nvma/.nvm/versions/node/v6.2.1/bin/eslint
npm config get prefix
>/home/nvma/.nvm/versions/node/v6.2.1

I've tried to use it locally too, but to no avail. I'm out of options.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

Actually, I don't understand why this is happening. I created #92 to add tracing options to better understand to which paths the module loading resolves and what exception occurred during module resolving.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@nvma quick question: how does the directory look like below >/home/nvma/.nvm/versions/node/v6.2.1

Can you let me know where exactly the eslint node module resides on disk in your setup.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@nvma and can you provide me with the output of npm root -g

from vscode-eslint.

draptik avatar draptik commented on August 16, 2024

I am also running into the same issue.

$ npm root -g
/home/patrick/.nvm/versions/node/v6.2.2/lib/node_modules
$ which eslint
/home/patrick/.nvm/versions/node/v6.2.2/bin/eslint
$ which node
/home/patrick/.nvm/versions/node/v6.2.2/bin/node
$ la ~/.nvm/versions/node/v6.2.2/lib/node_modules/
drwxr-xr-x  7 patrick users 4,0K 28. Jun 21:38 eslint/
  • OS: Arch Linux (64)
  • VSCode: 1.2.1
  • Node: 6.2.2
  • NPM: 3.9.5
  • ESLint: 2.13.1

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@draptik thanks. Could you also run 'npm config get prefix'. I have the felling global modules are resolved against the wrond directory when using nvm

from vscode-eslint.

Nighthawk22 avatar Nighthawk22 commented on August 16, 2024

@dbaeumer same problem here:

[:~] $ npm root -g
/Users/maxzollneritsch/.nvm/versions/node/v4.4.3/lib/node_modules
[:~] $ which eslint
/Users/maxzollneritsch/.nvm/versions/node/v4.4.3/bin/eslint
[:~] $ which node
/Users/maxzollneritsch/.nvm/versions/node/v4.4.3/bin/node
[:~] 127 $ ls -la  ~/.nvm/versions/node/v4.4.3/lib/node_modules/
total 0
drwxr-xr-x  10 maxzollneritsch  staff  340 13 Jul 10:09 .
drwxr-xr-x   4 maxzollneritsch  staff  136 12 Apr 21:32 ..
drwxr-xr-x  11 maxzollneritsch  staff  374 13 Jul 10:09 eslint
[:~] $ npm config get prefix
/Users/maxzollneritsch/.nvm/versions/node/v4.4.3
  • OS: OS X 10.11.5
  • VSCode: 1.3.1
  • Node: 4.4.3
  • NPM 3.10.5
  • ESLint: 3.0.1

Installing it locally on the root folder of the project works for me but for me its not really a nice way.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@Nighthawk22 this actually all looks ok. Can you do one thing for me: in /Users/maxzollneritsch/.nvm/versions/node/v4.4.3/lib/node_modules is there an eslint folder ?

from vscode-eslint.

Nighthawk22 avatar Nighthawk22 commented on August 16, 2024

@dbaeumer Is listed in my comment, yes there is one

from vscode-eslint.

p3k avatar p3k commented on August 16, 2024

I have the same issue, using prefix = ${HOME}/.local/lib/npm in ~/.npmrc

→ npm config get prefix
~/.local/lib/npm

→ which eslint
~/.local/lib/npm/bin/eslint

→ ls -n ~/.local/lib/npm/bin/eslint
lrwxr-xr-x  1 501  109  40 Jul 14 13:44 ~/.local/lib/npm/bin/eslint -> ../lib/node_modules/eslint/bin/eslint.js

from vscode-eslint.

madcampos avatar madcampos commented on August 16, 2024

I'm having this issue with a single file, a html opened from a folder with no eslint configuration file nor package.json, it's just that single file in the folder actually. And with a project that is configured, with package.json and .eslintrc.

I'm not using nvm and eslint is installed globally.
Here are the versions:

OS: Windows 10 build 14393
VS Code: 1.3.1
Node: 6.3
npm: 3.10.3
eslint: 3.1.1

Also, here are the npm commands:

madca@Freyr ~ $ npm root -g
C:\Users\madca\AppData\Roaming\npm\node_modules

madca@Freyr ~ $ npm config get prefix
C:\Users\madca\AppData\Roaming\npm

from vscode-eslint.

wooramy avatar wooramy commented on August 16, 2024

I had an similar issue after uninstalling old node version and I was able to fix it by resetting nvm default to latest node version.

Here's what happened.

[Repro Steps]

  1. nvm default was set to node version 0.10.x
  2. Installed vscode and eslint extension (which worked fine)
  3. Installed node version 4.4.x (still fine)
  4. Uninstalled node version 0.10.x (broken)
  5. Okay, ran 'npm install -g eslint' for new node version 4.4.x (still broken)
  6. Ah ha. nvm 'default' was gone once I had uninstalled the old Node version
  7. nvm alias default 4.4
  8. Relaunch vscode

Tada!

from vscode-eslint.

rickmed avatar rickmed commented on August 16, 2024

Mine works when the plugin uses the global eslint install but when I install eslint locally it does not work.

Using nvm
OS: Windows 10 x64
VS Code: 1.3.1
Node: 6.3
npm: 3.10
eslint: 3.1

from vscode-eslint.

ctumolosus avatar ctumolosus commented on August 16, 2024

This happens to me when I open a single javascript file that is part of a project with ESLint installed locally. For example, I use iTerm and run my watch script, whenever an error is reported I use CMD+Click to quickly open a file.

Ideally, it should find the ESLint package in my project, but I was able to fix the problem by adding { "window.openFilesInNewWindow": false } to VSCode user settings.

from vscode-eslint.

madcampos avatar madcampos commented on August 16, 2024

An update:
I ran into a similar issue (with nodemon not finding my script). It was caused by a custom script that runs on initialization for cmd.exe (configured via registry) that changes the working directory.
I removed the script, reopened vscode and esthe linting was working again.

from vscode-eslint.

Beatusvir avatar Beatusvir commented on August 16, 2024

I've run into this several times, besides the obvious failed installs or things like that. I noticed VSCode will not detect eslint if you current folder is not the project root. I mean, if your current workspace folder has no node_modules folder in there, it fails. I have to open the root folder for it to be detected. I'm not sure if there is a way to go around this or if it's a different issue.

from vscode-eslint.

vxzhong avatar vxzhong commented on August 16, 2024

"child_process.exec" use '/bin/sh' as the default shell, but I use 'zsh', so 'npm config get prefix' maybe failed because of the wrong shell.

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

I re-implemented the eslint module resolution algorithm (see microsoft/vscode-languageserver-node#77, https://github.com/Microsoft/vscode-languageserver-node/blob/master/server/src/files.ts#L103).

The new approach loads eslint from parent folders so you don't need to open the project root anymore. In addition it does NOT rely on npm config get prefix nor npm root -g. And it doesn't mess with the NODE_PATH anymore. So as long as the shell variables travel to VS Code eslint package resolving should be fine now.

I did various tests and things look good to me. However I kept the old resolution in and it can be enabled via "eslint._legacyModuleResolve": true. I will close this issue and will publish a new version of ESLint with the next update of VS Code. If you still see issues then open a new issue here.

from vscode-eslint.

FallenMax avatar FallenMax commented on August 16, 2024

I still run into this issue. I'm using yarn and my global eslint has path: /usr/local/bin/eslint.
By reinstalling eslint using npm instead of yarn, the extension can now resolve eslint (at /usr/local/lib/node_modules/eslint/lib/api.js) and run without problem.

from vscode-eslint.

BairDev avatar BairDev commented on August 16, 2024

@dbaeumer Should I comment this issue, if the problem has reoccurred? Or #92?

I still have this problem:

Failed to load the ESLint library for the document /home/path/to/my/file.js

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

Some versions:

ESLint: 1.2.7
VSCode: 1.10.2
nvm: 0.33.1
node (current): 6.10.0
Linux Kernel: 4.8.0-41-generic

You've said, that ESLint does not use npm config get prefix or npm root -g anymore, but just in case you might need them:

npm config get prefix
-> # /home/myName/.nvm/versions/node/v6.10.0

npm root -g
-> # /home/myName/.nvm/versions/node/v6.10.0/lib/node_modules

ESLint has been installed In the last folder.

Finally there are some weird lines in my .bashrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

Thanks!

from vscode-eslint.

dbaeumer avatar dbaeumer commented on August 16, 2024

@BairDev how did you install eslint globally. Using yarn?

I just checked and the ESLint extension works correctly if:

  • global module is install using npm
  • npm get config prefix returns the location where the global eslint is installed.

from vscode-eslint.

BairDev avatar BairDev commented on August 16, 2024

@dbaeumer Sorry for kind of spamming this issue, but the problem has disappeared. I've just created a .eslintrc and then the stuff started to work. Thanks anyway.

But in order to answer your question: I've installed eslint via npm install -g, if I remember correctly. We have a quite complex project set-up, with using npm link and stuff like that, maybe this was the reason for the hiccup.

from vscode-eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.