-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
SublimeLinter doesn't recognize linters installed with NVM #128
Comments
NVM isn't supported. |
@aparajita That doesn't make much sense, if there's a setting for the path that should make it work. Why does the plugin keep looking in /usr/bin/env |
That question can't be answered without seeing the complete debug output from the console. |
|
That isn't the complete output. I need to see everything from startup. |
|
Like I said at the beginning, nvm isn't supported. I kind of knew what I was talking about. nvm works by modifying PATH (or by looking at a .nvmrc file) in the current shell, and thus is only effective when running node from the shell. SublimeLinter isn't running in your shell's environment, it's running in Sublime Text's environment, which is inherited from the shell it is launched from. But if the application is launched, it doesn't inherit from a shell. The first line of jshint is So like I said, nvm isn't supported currently because it only works within the exact shell from which you issue commands. In fact, even within a shell, as soon as you open a new shell, it has no idea that nvm has modified PATH. You can have different versions of node running in different shells simultaneously. So how is SublimeLinter supposed to know which one you want it to use? Support could be added for .nvmrc files, but that will have to be done by someone else. This is open source, I welcome contributions. |
+1 |
@majimboo Sorry to say that votes won't help. Someone (other than me) has to come forward and implement nvm support. |
This code works well for the latest node installed through nvm:
|
Actually this can easily be fixed by aliasing the version with nvm to default. Restart. Profit. |
This is one of the (many) reasons I use n instead of nvm: This may also be an option (haven't tried it myself) |
For those interested in this issue, you may want to check out the NodeLinter class I added recently. It's a work in progress, but I'm looking to support the following features:
I don't see any reason why nvm support couldn't be added to the NodeLinter class. Another great feature, which some might think goes too far, but would be super cool would be to have a mapping from module name to sublimelinter plugin and automatically install a missing linter plugin (disabled by default of course) if it detects that a Node project depends on that linter. https://github.com/SublimeLinter/SublimeLinter3/blob/master/lint/node_linter.py |
From my experience, there is absolutely no problem using
brew install nvm
nvm install iojs
nvm use iojs
# Ensure that a non-login, non-interactive shell has a defined environment.
if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
source "${ZDOTDIR:-$HOME}/.zprofile"
fi
# Set download dir
export NVM_DIR=~/.nvm
# Load nvm script
if [[ -s $(brew --prefix nvm)/nvm.sh ]]; then
source $(brew --prefix nvm)/nvm.sh
fi
npm install -g jshint jscs
Hope this helps! |
@majimboo It's works great! Thanks. |
It works for me "paths": {
"linux": [],
"osx": [
# I have installed jshint here
"/PATH/TO/HOMEDIR/node_modules/.bin/",
# Without this line a got error
# SublimeLinter: WARNING: no jshint version could be extracted from:
# env: node: No such file or directory
"/PATH/TO/HOMEDIR/.nvm/current/bin/"
],
"windows": []
}, |
I was having issues but once I did |
I solved this problem by adding the following:
to I think the problem is solved by the documentation, but I hope my comment will help others who find their way here via web search. |
@chrisl8 thanks for your help! |
Fixed my problem too. Thx. |
Anyone having problems with @chrisl8 answer not working on OSX:
|
@aparajita Why not supported? Isn't it as simple as what HTML Prettify guys did by introducing a way to have a config saying where node is installed if its not installed already? |
Not saying it can't be done, just saying it isn't currently. If it seems simple, please feel free to contribute! Thanks! |
Did what @thymikee suggested and it fixed it for me. I guess it makes sense that sublime doesn't look at zshrc or bashrc, since at least on linux only .*profile gets read when you log in and startx. |
@YRodriguezO, Please watch your language, that is not appropriate behavior. |
@YRodriguezO That kind of language is not welcome here, and your comment is incoherent besides. Please leave. |
So since people have posted workarounds I'm closing the issue. |
@chrisl8 Mine too! Thx!
|
Here is what I did (sort of the combination). In your
And then Cmd+Shift+P, search for SublimeLinter: Clear Caches and clear the cache. (not sure if this was necessary). I use zsh with prezto this is my
|
I saw that there was a point on the SublimeLinter-jshint page:
I then added my nvm initialiser shell script (the line above which @nodkrot has written) into the |
This is how I solved it: Open "SublimeLinter Settings" and add path to Node:
And remember to read the docs :) |
For me, like @nodkrot , the problem was that I was using NVM and ZSH. In fact, I'm using Oh My Zsh as well. By the way, this was also staring me in the face in the "If you are using nvm and zsh, ensure that the line to load nvm is in This problem was, I believe, also exacerbated by the fact that I had no "system" installation of Node...otherwise this would have presented itself differently, or not at all since it would have found a node. |
with version 4.0.5, paths eg
|
I thought that this is documented in the README, but it isn't. Happy to take documentation PRs. Here is some info for the new SL4 |
Worked for me:
|
This sounds like it could be caused by sublimehq/sublime_text#1877 For me, I get the error in the OP, but then SublimeLinter kicks in after a few seconds. |
@kaste - thank you! Here is how I got my n installation to work:
I got the path to my n node executable by running:
|
@brainthinks what does $PATH do? Do I add it to the end of my |
I do not think it is a good idea. as most comments here suggest to add note the hardcoded version of node that is referenced maybe you're just working on a single app. Maybe your only using one version of node for all you developer needs. but as this is related with nvm one assumes there are multiple versions of node in play. on linux you just reference .nvm in your home folder Rather than running eslint against a specific version of node each time as is the case with the above. |
Had the same problem running Linux Mint 18.3 and node installed with nvm.
to your And the second problem was
@brainthinks Thank you for the |
@rreckonerr's solution fixed SublimeLinter using the wrong node version for me, which resulted in the error "SyntaxError: Use of const in strict mode." in case anyone else is encountering that. Sticking the nvm path in there works just fine. |
Installing this fixed it for me: https://github.com/int3h/SublimeFixMacPath |
This Worked for me. |
You can setup symlink for current nvm version of node to ln -sf /Users/iknpx/.nvm/versions/node/$(nvm current)/bin/node /usr/local/bin/node |
@rreckonerr This solution worked for me on macOS Catalina on zsh terminal and nvm. Thank you! |
Also confirm the following below
Obviously replace the username |
I know this is a super old (recurring) topic...but there aren't any solutions that allow SublimeLinter to use project-specific node versions in parallel (different node versions). So I'll add one. This isn't exactly sublimelinter's problem...but it is a general problem as more languages move towards project-specific interpreter/runtime versions and project-specific dependencies (python venv, nodejs .nvmrc, etc). The linter/linter-version may be project-specific dependency rather than a global install (supports CI, common basis for teams, etc). The project linter version may depend on a specific interpreter/runtime version (python, nodejs, etc). A system may have many different versions of an interpreter/runtime installed and different mechanisms to activate a given version for a project (venv, nvm, etc). There is a reasonable work-around that allows you to use multiple different node versions (via nvm) in sublime in parallel. Only downside is that it requires using sublime-project files (open as project instead of dir) in order to have project-specific linter configs (PATHs) (ie different node versions for different projects). Sublime/linter are not nvm-aware...they just rely on Sublime sourcing dotfiles at startup and then finding stuff on the PATH. only one node version across all of sublime (not optimal)So sublime sources your dotfiles on startup...so it will get PATH/etc from there...to ensure that sublime (and therefore sublimelinter) can find the node version you want.
However! The point of nvm is that you can run multiple version of node/npm in parallel. The above means you get a single node/npm version for all of sublime-land. Which is not a problem if you only work on a single project with a single version of node/npm at a time.
If you can live with only one project (and node version) at a time, then you can use: export NVM_SYMLINK_CURRENT=true # creates $NVM_DIR/current/bin/ symlink pointing at latest nvm use version
nvm use # run from your project dir. assuming you have .nvmrc in your project dir specifying project version. ...and THEN start sublime (so PATH="${NVM_DIR}/current/bin/:$PATH" This will ensure that whatever the latest You also need to make sure you aren't re-running nvm in your dotfiles if nvm is already initialized. ie default nvm dotfile stuff needs to be wrapped in some check (like if If you have 2 different node projects open at the same time that each use a different node version, then just relying on single/global sublime PATH to pick the right node version won't cut it. multiple node (via nvm) versions in parallel in sublimeAlternatively... if you can live with opening Sublime project files instead of opening project folders (I find this annoying to remember), you can use So I also add some preparation on the npm package side that we can then use in our sublime project file. For instance, I've setup my
Note that I moved the nvm dotfile stuff into a dedicated This creates a special directory symlink
example sublime-project file {
"folders":
[
{
"path": "."
}
],
"settings":
{
"SublimeLinter.linters.eslint.enabled": true,
"SublimeLinter.linters.eslint.env": {
"PATH": "${folder}/node_modules/.bin:${folder}/.node_dir/:${PATH}"
},
}
} With all that you get a working sublime project out of the box (after npm init) assuming you have nvm on your system. But you do need to open from the project menu rather than opening dir from file menu...otherwise the sublime project file is ignored and the paths set there for your linters are not picked up. |
I have a few linters installed with NVM (jshint, csslint) and Sublime Linter won't recognize them. I've added the path to my settings but according to my console SublimeLinter is still looking in the wrong place.
Here's my SublimeLinter settings.
https://gist.github.com/ec03df57e48eac45263b
The text was updated successfully, but these errors were encountered: