gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

Downloaded node binaries are not available in the PATH

Open fbecart opened this issue 8 years ago • 1 comments

Hi,

I have an issue specific to the fact that I use Lerna. Here is an extract of my root build.gradle:

buildscript {
    repositories {
        jcenter()
    }
}

node {
    version = '8.1.3'
    download = true
}

task lernaBootstrap(type: NpmTask) {
    dependsOn npmInstall

    args = ['run', 'lerna', 'bootstrap']
}

When npm run lerna bootstrap is executed, multiple npm processes will be started to download the dependencies of each Node project. Lerna uses the binaries (npm) available in the PATH.

Currently, the directory where the binaries are downloaded is not available in the PATH. As a result, Lerna uses the system version of npm instead of the downloaded one.

My workaround has been the following to build.gradle:

afterEvaluate {
    Map environment = [:] << System.getenv()
    environment.PATH = "${node.variant.nodeBinDir}:${environment.PATH}"
    lernaBootstrap.environment = environment
}

I imagine a better fix could be to let the plugin add the download directory to the PATH.

fbecart avatar Jul 12 '17 09:07 fbecart

It's strange to me, that nobody else has been looking for this solution

VBourdine avatar May 29 '18 14:05 VBourdine