SublimeLinter: NVM: cannot locate 'eslint' / 'node' etc
After recent update, Sublime always popup the tips:
SublimeLinter: WARNING: eslint cannot locate 'eslint'.
In detail:
I haven’t install global eslint, because I have to extend the eslint rules in config file in projects, If using the global eslint, the xxx-eslint-config package is not used.
When the project is configed properly, and with local eslint installed, everything works very well.
But if I open a file not in project (in a single window), there always a popup tips in the sublime console.
In previous versions (not sure which version), no such problem.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 61 (24 by maintainers)
@TooBug
I was seeing the
env: node: No such file or directoryerror as well.I’m on OSX. I had recently uninstalled node with brew, which means it was no longer at
/usr/local/bin/node. I installed a previous version of node with brew: runningwhich nodereturned/usr/local/opt/node@8/bin/node.I figured Sublime Linter didn’t know about this node executable, even though it’s in my
$PATH, so I just symlinked it to /usr/local/bin by runningln -s /usr/local/opt/node@8/bin/node /usr/local/bin/node. After that Sublime Linter could find node again and the error went away.@braver @kaste On OSX, I can confirm that adding the following to Sublime Linter’s settings does not solve the problem.
However, the fix suggested here does solve the problem. In other words, adding this works:
I don’t know how Sublime Linter resolves paths, but it seems that if
SublimeLinter-eslintcan be fixed by adding a PATH to itsenvsetting which is already in the user’s$PATH, thenSublimeLinter-eslintshould be able to pull in the user’s$PATHand not require the user to change anything in his settings.I figured it out. It’s because i’m using NVM, so I had to add the correct executable path in SublimeLinter’s settings
Same problem, new version installed automatically and everything is now broken.
@braver I’ve viewed similar issues, but seems no one describes my situation.
IN PROJECT:
STANDALONE FILE:
For those coming here with this problem: I found that in a project using only eslint the
solution works, but on a project using both eslint and sassLint it didn’t. so I ended up combining the
linterssolution and it now seems to work fine with bothI suspect that I could yank the path solution and the eslint solo project would work, but I didn’t try it.
This worked for me like a charm in Catalina. Make sure that eslint is installed via npm of-course.
Pretty unfortunate that I have to add a global
.eslintrcto my home directory for this plugin to not display a big error message on every file in a project where I don’t have eslint setup. Would be nice if there was a setting that could disable this warning globally instead.I have the same exact issue as @TooBug – is there a fix for this yet? it’s really annoying
This is an issue with Sublime Text: https://github.com/SublimeTextIssues/Core/issues/1877. ST core devs are aware of the issue and it has been moved upward in their priority list.
@kylebebak The
pathssetting is only used to find executables. If an executable depends on having other executables available in the environment, that’s not enough. Eslint needs node, so you need to patch the environment as you did.The core of the problem here is that NVM takes too long, in certain setups, to report the actual environment to Sublime Text. Your shell only gets about a second to do so, after that your stuck with the environment desktop applications get by default, which on macOS is not the environment you get when you open Terminal. @nodkrot you may not run into this issue if you don’t use nvm on the other machine, or the other machine is simply faster and does report the environment to ST before it times out.
Behavior of Sublime Text changed in 3.1 to have this 1 second time out, and thereby also removing the possibility for plugins to create a work around. The TS issue linked here doesn’t seem to actually resolve this issue and in any case the actual problem and possible solutions changed recently in Sublime Text 3.1 (and this issue is older than that).
Not working for me! I tried everything here. Sublime seems broken tbh, too much work to get a simple lint to work 😦
I got stuck on the
env: node: No such file or directoryerror, and none of the proposed solutions worked (updatingpaths.osx, updatinglinters.standard.env.PATH). I’m running macOS High Sierra, using zsh with oh-my-zsh, using NVM, and I was trying to use thestandardlinter installed in my project, rather than a global install.I finally got things working by using the
executableoption, in my project settings, to point to Node and Standard as well. Here’s what I added:It might be worth looking at what
GoSublimeis doing - even when my sublime isn’t loading my path correctly, GoSublime seems to do its own path loading and reports the results to sublime’s console.EDIT: Since we’re posting what fixed this for us, I fixed this issue by upgrading to Arch Linux from macOS.
As @bdefore commented 4 days earlier, @thislogancall 's change to settings doesn’t fix the error. My sublimelinter settings:
{ [....] "paths": { "osx": ["~/.rvm/gems/ruby-2.3.3/bin", "~/.nvm/versions/node/v10.0.0/bin", ] }, [...]