Comments (36)
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 the
vscode-eslint` should not be activated.
from vscode-eslint.
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.
The ESLint extension has currently no support for globally install eslint module via yarn. I opened: #187
from vscode-eslint.
Hmm. this works for me with a locally installed eslint and 0.10.8. See screen shot
@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.
@egamma are you using nvm? I'm experiencing this issue as well on my machines that have nvm installed.
from vscode-eslint.
Sorry, looks like the original issue author was @Ciget
from vscode-eslint.
@dbaeumer, nop, even after remove this variable from env settings and restart - still have this issue.
from vscode-eslint.
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.
@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.
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.
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.
@unional agree. Please see: #68
from vscode-eslint.
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.
@GeorgeSapkin thanks for the insight. Didn't even know that this is possible.
from vscode-eslint.
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.
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.
@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.
@nvma and can you provide me with the output of npm root -g
from vscode-eslint.
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.
@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.
@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.
@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.
@dbaeumer Is listed in my comment, yes there is one
from vscode-eslint.
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.
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.
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]
- nvm default was set to node version 0.10.x
- Installed vscode and eslint extension (which worked fine)
- Installed node version 4.4.x (still fine)
- Uninstalled node version 0.10.x (broken)
- Okay, ran 'npm install -g eslint' for new node version 4.4.x (still broken)
- Ah ha. nvm 'default' was gone once I had uninstalled the old Node version
- nvm alias default 4.4
- Relaunch vscode
Tada!
from vscode-eslint.
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.
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.
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.
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.
"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.
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.
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.
@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.
@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.
@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)
- Not work of "source.fixAll.eslint": "explicit" on v3.0.10 HOT 3
- Tslint takes hours to process HOT 1
- Document behavior and defaults of useFlatConfig across ESLint v8, v9, v10 HOT 2
- [Suggestion] Mark `warn` eslint level as vscode `DiagnosticSeverity.Information` `info` level HOT 3
- `eslint.execArgv` Configuration is Not Working HOT 3
- JSON schema for useFlatConfig can be more specific HOT 1
- Should plugins still have `eslint.experimental.useFlatConfig` in their settings? HOT 1
- Support custom clickable links in eslint error tooltips HOT 1
- The extension does not show any errors anymore HOT 3
- Enfore validate list
- Error output (in flat config) causes problems not to appear in the output channel HOT 2
- Add support for ESLint feature flags HOT 4
- Restarting an extension when that extension's output is selected in the "Output" pane should not change which extension is selected in the "Output" pane. HOT 3
- ESLint with SafeQL crashes on Windows with error code 3221226505 HOT 5
- About eslint config,When user setting and workspace setting are conflict,how to override user settings config HOT 1
- ESLint is preventing my files from being saved HOT 7
- eslint autofix for multiple empty lines don't work HOT 1
- ESLint server only looks at first entry in `context.only` array sent along with `textDocument/codeAction` HOT 4
- Supervied Idenification Verification Profile HOT 2
- Setup ESLint with Deno runtime instead of node HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-eslint.