-
Notifications
You must be signed in to change notification settings - Fork 455
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
Feature request: Add ability to extend PATH environment variable for the npm process #1381
Comments
@yevhensayenko I'm trying to reproduce your problem, but it works for me when I'm using the node plugin and specify that npm using Can you provide extracts from your build file regarding |
I'm currently experimenting with an API like this (Option 1): prettier()
.npmExecutable('/path/to/npm')
.npmEnv(['PATH': '/path/to/node-dir' + ':' + System.getenv('PATH')]) This would allow for passing various env-vars to the node process and would also solve the gradle-node-plugin requirements. But I'm unsure if this is the way to go, as this api seems to be a bit too "open"? Maybe it would be sufficient to offer an API like this (Option 2): prettier()
.npmExecutable('/path/to/npm')
.nodeExecutable('/path/to/node') -> I would then internally use the nodeExecutable-path to add it to the PATH-env variable passed to the node process. I'm leaning toward Option 2 as it is cleaner and fits better with the current API, but would like to hear your thoughts and comments @nedtwigg and @yevhensayenko ? |
I agree that option 2 is clearer. |
Just a small note. This will not actually solve the use of the gradle node plugin. That plugin needs to use a task in order to install node. Since prettier is evaluated at configuration time, and attempt to do the npm install at this time, the node gradle plugin can't resolve the issue. Below is an example of using the objects of the node gradle plugin to install at configuration time. Maybe it would be best to have a SetupPrettier task that registerInternalDependencies (or some other task) that verifies npm and does the npm install instead of doing this at configuration time.
|
Currently one needs to first setup node (using a gradle call like |
Released in |
I would like to use local nodeJS, that is downloaded into project dir using https://github.com/node-gradle/gradle-node-plugin. I tried to specify npm executable using using
prettier().npmExecutable('<path to project>/.gradle/nodejs/node-v16.18.0-linux-x64/bin/npm')
. But it still expects node command to be present. So the only way to set it up for me was to override PATH using command line likePATH=/<path to project>/.gradle/nodejs/node-v16.18.0-linux-x64/bin:$PATH ./gradlew
.But it seems that we could do it by overriding PATH variable using
java.lang.ProcessBuilder#environment()
incom.diffplug.spotless.npm.NpmProcess#npm
. So, I think it would be helpful to be able to set up node bin directory in settings, so it can be then added into PATH environment variable for the process.The text was updated successfully, but these errors were encountered: