Skip to content

Commit eadf2d7

Browse files
author
ntwigg
committed
Fix NodePlugin behavior on Heroku.
1 parent 6ae7337 commit eadf2d7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Webtools releases
22

33
## [Unreleased]
4+
### Fixed
5+
- Add the node installation dir onto `PATH` to try to fix a Heroku issue.
46

57
## [1.2.3] - 2025-08-07
68
### Fixed

src/main/java/com/diffplug/webtools/node/NodePlugin.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ public void npmCiRunTask() throws Exception {
130130

131131
ProcessBuilder processBuilder = new ProcessBuilder(npmExe.getAbsolutePath(), "run", npmTaskName);
132132
processBuilder.directory(projectDir);
133+
134+
addNodeToPath(processBuilder, installDir);
133135
processBuilder.environment().putAll(environment);
134136
Process process = processBuilder.start();
135137

@@ -163,6 +165,19 @@ public void apply(Project project) {
163165
project.getExtensions().create(EXTENSION_NAME, Extension.class, project);
164166
}
165167

168+
private static void addNodeToPath(ProcessBuilder processBuilder, File installDir) {
169+
// Add node binary directory to PATH for npm to find node executable
170+
File nodeDir = new File(installDir, "node");
171+
String currentPath = processBuilder.environment().get("PATH");
172+
if (currentPath == null) {
173+
currentPath = processBuilder.environment().get("Path"); // Windows
174+
}
175+
String nodeBinPath = nodeDir.getAbsolutePath();
176+
String pathSeparator = System.getProperty("path.separator");
177+
String newPath = nodeBinPath + pathSeparator + (currentPath != null ? currentPath : "");
178+
processBuilder.environment().put("PATH", newPath);
179+
}
180+
166181
private static String nvmRc(File file) throws IOException {
167182
String str = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8).trim();
168183
return "v" + str;

0 commit comments

Comments
 (0)