Multiple NodeJS versions running on Win10 and having git problems
Hi all,
I guess, I have a very specific topic but perhaps someone can help me.
I gave multiple node version installed on my Win10 machine with the newest one (v11.12.0) in standard path environment variable. In my path variable is also a directory "batch" where I have several batch files, one of those is a node-switch.bat which adds the path to another node version as the first path in the path environment variable and also executes the corresponding nodevars.bat. With this, I can have multiple node version installed on my windows system and use whichever one I need for a project.
For one project I use node v08.16.0 and yarn as package manager. This works perfectly on the console with my current setup and batch files.
Now, when I want to commit and push my changes to Github, we execute some scripts. Some of them involve yarn (i.e. "yarn prettier --write"). This works totally fine in my console.
But in IntelliJ, the standard node version (v11.12.0) is executed. I guess, it's because git executes this and not IntelliJ (because in IntelliJ the yarn commands work fine). I totally understand, that git executes the standard node version as in git's context, the node version hasn't changed and nodevars.bat is not executed.
So my question is, can I change PATH variable for the loaded project in IntelliJ when it executes git(-hooks)?
Yours
Graphity
Please sign in to leave a comment.
Hi,
You can start IntelliJ from a console where PATH variable is already changed properly.
Another way is to modify your git hook to modify PATH (run node-switch.bat/odevars.bat) prior to executing "yarn prettier --write". Seems it should work too.
Hope it will help.
Hi Sergey,
thank you for your ideas!
I think, I won't be able to change our git hook since the other developer uses macOS. This might break his process then :(
I will have to rely on git CLI.
Thanks anyway!
Thanks, I see. Then, starting IntelliJ from console (where PATH variable is already changed properly) will likely help.
You should be able to change the hooks without modifying the version saved in the repo. Hooks are in fact local to the repo - stored in .git/hooks in the project repo, and are not shared.
There are tools that allow sharing the hooks via repo, but essentially, they link/copy the hooks to the mentioned folder.
Hi guys,
thank you for you input!
We are using husky as git hook ... thingy (I don't really know what it is, but I understand it's something about git hooks).
I tried a fast approach and just hacked some command lines into .git/hooks/pre-commit but it didn't work out. I didn't took the time to investigate, yet. I will keep you updated on this.
About starting IntelliJ with PATH variable: I guess, I can use it (didn't try it). I, for now, open a command line to commit as I'm familiar with git on CLI and then I don't have to restart IntelliJ :)
Yours
Raul