From ca1fc8fb062f5380b0c702c6a49c66b6f37fedc2 Mon Sep 17 00:00:00 2001 From: Burak KALAYCI Date: Fri, 21 Aug 2026 13:39:03 +0300 Subject: [PATCH 1/2] fix: drop --scripts-prepend-node-path from npm start npm 12 treats unknown CLI flags as errors. Node is already on PATH via the process environment, so the flag is unnecessary. Fixes #3024 --- .../npm/StandardNpmProcessFactory.java | 5 +- .../npm/StandardNpmProcessFactoryTest.java | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 lib/src/test/java/com/diffplug/spotless/npm/StandardNpmProcessFactoryTest.java diff --git a/lib/src/main/java/com/diffplug/spotless/npm/StandardNpmProcessFactory.java b/lib/src/main/java/com/diffplug/spotless/npm/StandardNpmProcessFactory.java index 7b95db7740..a7f0313ce4 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/StandardNpmProcessFactory.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/StandardNpmProcessFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2025 DiffPlug + * Copyright 2023-2026 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,10 +129,11 @@ public NpmServe(File workingDir, NpmFormatterStepLocations formatterStepLocation @Override protected List commandLine() { + // npm 12 rejects --scripts-prepend-node-path (unknown CLI flag). Node is already + // on PATH via environmentVariables(), which is what that flag used to do. return List.of( npmExecutable(), "start", - "--scripts-prepend-node-path=true", "--", "--node-server-instance-id=" + nodeServerInstanceId); } diff --git a/lib/src/test/java/com/diffplug/spotless/npm/StandardNpmProcessFactoryTest.java b/lib/src/test/java/com/diffplug/spotless/npm/StandardNpmProcessFactoryTest.java new file mode 100644 index 0000000000..2a114a9774 --- /dev/null +++ b/lib/src/test/java/com/diffplug/spotless/npm/StandardNpmProcessFactoryTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2026 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.spotless.npm; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.nio.file.Path; +import java.util.List; +import java.util.UUID; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +class StandardNpmProcessFactoryTest { + + @Test + void npmServeCommandLineOmitsRemovedScriptsPrependNodePathFlag(@TempDir Path tmp) { + File npm = tmp.resolve("npm").toFile(); + File node = tmp.resolve("node").toFile(); + File project = tmp.resolve("project").toFile(); + File build = tmp.resolve("build").toFile(); + project.mkdirs(); + build.mkdirs(); + + NpmFormatterStepLocations locations = new NpmFormatterStepLocations( + project, + build, + null, + new NpmPathResolver(npm, node, null, List.of())); + NodeServerLayout layout = new NodeServerLayout(build, "{\"name\":\"spotless-prettier\"}", "console.log('hi');"); + UUID serverId = UUID.fromString("00000000-0000-0000-0000-000000000001"); + + NpmLongRunningProcess process = StandardNpmProcessFactory.INSTANCE.createNpmServeProcess(layout, locations, serverId); + + assertThat(process.describe()) + .contains("start") + .contains("--node-server-instance-id=" + serverId) + .doesNotContain("scripts-prepend-node-path"); + } +} From 215bda23b2b80ff1ae5a31517a251a02c7a6b79d Mon Sep 17 00:00:00 2001 From: kalayciburak Date: Sat, 22 Aug 2026 20:36:35 +0300 Subject: [PATCH 2/2] docs: changelog entries for npm 12 prettier start Add Unreleased Fixed bullets in lib, gradle, and maven changelogs. --- CHANGES.md | 2 ++ plugin-gradle/CHANGES.md | 1 + plugin-maven/CHANGES.md | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a80b1c0778..519eb34301 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,8 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Fixed +- Prettier and other npm-based formatters no longer fail to start on npm 12 (`EUNKNOWNCONFIG` from `--scripts-prepend-node-path`). ([#3024](https://github.com/diffplug/spotless/issues/3024)) ## [4.10.0] - 2026-08-17 ### Added diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 6618d9e70c..368856e278 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -4,6 +4,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] ### Fixed +- `prettier()` and other npm-based steps no longer fail to start on npm 12 (`EUNKNOWNCONFIG` from `--scripts-prepend-node-path`). ([#3024](https://github.com/diffplug/spotless/issues/3024)) - `spotlessInternalRegisterDependencies` now writes its output under a build directory that is configured after the plugin is applied, instead of always under the default `build/`. ([#2114](https://github.com/diffplug/spotless/issues/2114)) ## [8.10.0] - 2026-08-17 diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 604ae246b2..01f5f77385 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,6 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Fixed +- `` and other npm-based steps no longer fail to start on npm 12 (`EUNKNOWNCONFIG` from `--scripts-prepend-node-path`). ([#3024](https://github.com/diffplug/spotless/issues/3024)) ## [3.10.0] - 2026-08-17 ### Added