node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
603 stars 118 forks source link

question: how does this plugin determine which version of node to use? (when download = false) #255

Closed ptolemybarnes1649 closed 6 months ago

ptolemybarnes1649 commented 1 year ago

I'm asking this question as I've seen some surprising behaviour where the plugin uses a version of node that is not the default (as set by nvm).

Thanks for your help.

deepy commented 1 year ago

With download = false it's essentially what comes up first in your PATH so should be the same thing as if you open a terminal and type node or npm (keeping in mind that your .zshrc or similar may change this and those changes may or may not be reflected depending on how you run)

deepy commented 1 year ago

Are you using Windows? Taking a closer look at the logic behind this https://github.com/node-gradle/gradle-node-plugin/blob/8d4e9910274a1b26dcdb761d2892b73efef54826/src/main/kotlin/com/github/gradle/node/variant/VariantComputer.kt#L38-L43 I realize that with download set to true it'll use node.exe instead of node but with download set to false it'll always use node

Which could get relevant if you have a node.cmd or node.bat, which is generally fine

If you're not, it could be that depending on how you run the nvm changes haven't been properly applied, easiest way to test this is probably to create an ad-hoc test and print the content of PATH

ptolemybarnes1649 commented 1 year ago

@deepy Not on windows - I'll try your suggestion of printing PATH.