-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
husky with sourcetree : Can't find node in PATH, trying to find a node binary on your system #390
Comments
@zhaozhe0831 I have same problem when I switch |
It's actually not an error, just an information message. But it may sound like an error, especially as the output is red. Node version managers works by modifying the PATH when the terminal is started. GUI clients usually don't work well with version managers as they don't source .bashrc or .zshrc where version managers are usually initialized. So this message is just to let you know that husky will go into a mode where it'll try to find a Node binary (it uses run-node for that). Here's more documentation |
You need to set your system-wide node version to 8 or higher:
|
my default is
But I still get the same thing above when trying to commit with Sourcetree. |
I found somewhat of a reason/solution for the issue with Sourcetree. All of my dependencies are current, node, husky, lint-staged and no solution works but this, https://stackoverflow.com/questions/52754063/git-push-failed-due-to-husky-pre-push-on-sourcetree |
In my MAC, I fixed this by:
which node
/usr/local/bin/node
# ...
export PATH="/usr/local/bin:$PATH" |
I had the same issue with Webstorm. If anyone is using fnm, then the command to fix it would be:
|
This happens to me in Visual Studio Code if there's an linting error in the code, which we take care of in the pre-commit hook using eslint. vscode will display
in a pop up, even though it isn't the actual error, making it confusing for people to see what the real problem is (unless they check the output log). If the commit goes through, there's no popup. Does anyone have an idea how I can get vscode to display the actual error instead of this? |
I was experiencing this error with NVM & WebStorm (while everything was fine from the Ubuntu terminal). In a nutshell, it's just a path problem with NPM & GUI vs terminal as @typicode suggests. In my case, I ended up configuring
|
@sainnr solution worked for me on Catalina/zsh |
The last one works for me as well |
thank you @sainnr |
on my mac Mojave, I fixed this by: Check Node path:
Add this path to the globals PATHs:
enter edit mode by typing
and save it |
I opened a related issue on the SourceTree Jira: Basically the same issue with the PATH not including |
It works for me. My machine is macOS mojave 10.14.6(18G2022)
|
If you're using macOS and NVM, then that's the proper solution: just create
NOTE: it using your .bash_profile where NVM initialization should be already defined earlier when you installed NVM. I.e. next should be there already:
|
|
In my case @sainnr solution (#390 (comment)) was almost there, I was missing export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use |
This worked for me (and other Git apps that were having issues). This is on a Mac. |
This doesn't solve the issue though, it just stops the hooks from firing altogether. +1 for downgrading to |
Hi, guys, I met the same issue, here is how I fix it. 1.firstly, this is about the Node path problem, I try to change my .bash_profile, but it does still not work, so I installed "nvm" Two ways to install
3.after finished step 3 you can input 'nvm ls' in your terminal if you can successfully use this command, you can skip stepping 5, if you still can not use 'nvm command', skip stepping 4
then update
BTW: if you need to fix it immediately you can use your terminal to 'git commi't your changes |
I've spent some time figuring it out. Here's a fix that should work in any situation, though I tested it only on MacOS Big Sur with node installed via IssueThe thing is that SourceTree git hooks run within "clean" context and we need to add our node directory into that context. Husky enables that to us, as it runs SolutionRun:
This will create
|
Closing as many solutions have been provided (thank you! 👍 ) See also https://typicode.github.io/husky/#/?id=command-not-found (works for v4 and v5) |
None of the solutions worked for me.
|
Thank you! This worked to resolve this with sourcetree on Mac! |
After executing |
This comment made it work for me! #390 (comment) |
this worked for me 🕺 |
work for me #390 (comment) |
BTW, SourceTree just released a new version on 2021-08-23 that fixes this issue for me! Now it works regardless if I open SourceTree via command line or via Application icon. |
When I do that it bypasses the precommit. and it couldnt find node in terminal.. |
This worked for me too. |
In my case:
This was the error I was getting and this is the way I fixed and make it work: Solution
# Load Yarn command coming from homebrew
export PATH="/opt/homebrew/bin/:$PATH"
# This loads nvm.sh and sets the correct PATH before running hook
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use default |
The problem appears to be related to using nvm and changing node versions since after I switched versions I was unable to commit anything, however, opening Sourcetree from the terminal works for me...
|
this worked for me |
I faced the similar issue. The problem was that another program had added PATH changes to ~/.zshrc (.bashrc if you use it) Problem
Solution
Checking |
I'm trying to use husky precommit with sourcetree. The precommit command is run but i get the following error:
Does anybody know what's wrong? I'm using n.
OS: macOS Mojave 10.14
Node: 10.13
$ which node
: /usr/local/bin/nodenpm: 6.4.1
$ whick npm
: /usr/local/bin/npmThe text was updated successfully, but these errors were encountered: