Skip to content

prettier incompatibility with npm 12 #3024

Description

@klafbang

I use spotless 3.10.0 with npm + node installed via maven frontend for CI.

When running with npm 11.19.0 it works fine, but when I upgrade to npm 12.0.2, at least prettier fails with

Aug 19 22:06:00 [INFO] [BEGIN] Starting npm based server in /Users/michael/java/pairwise-comparison/target/spotless-prettier-node-modules-1cf7fada45e1395505a647d448bc2252 with StandardNpmProcessFactory.
Aug 19 22:06:00 [INFO] [END] Starting npm based server in /Users/michael/java/pairwise-comparison/target/spotless-prettier-node-modules-1cf7fada45e1395505a647d448bc2252 with StandardNpmProcessFactory. (took 4ms)
Aug 19 22:07:00 [INFO] creating formatter function (starting server)
Aug 19 22:07:00 [INFO] [BEGIN] Starting npm based server in /Users/michael/java/pairwise-comparison/target/spotless-prettier-node-modules-1cf7fada45e1395505a647d448bc2252 with StandardNpmProcessFactory.
Aug 19 22:07:01 [INFO] [END] Starting npm based server in /Users/michael/java/pairwise-comparison/target/spotless-prettier-node-modules-1cf7fada45e1395505a647d448bc2252 with StandardNpmProcessFactory. (took 11ms)
Aug 19 22:08:01 [INFO] creating formatter function (starting server)
Aug 19 22:08:01 [INFO] [BEGIN] Starting npm based server in /Users/michael/java/pairwise-comparison/target/spotless-prettier-node-modules-1cf7fada45e1395505a647d448bc2252 with StandardNpmProcessFactory.
Aug 19 22:08:01 [INFO] [END] Starting npm based server in /Users/michael/java/pairwise-comparison/target/spotless-prettier-node-modules-1cf7fada45e1395505a647d448bc2252 with StandardNpmProcessFactory. (took 5ms)

or, it doesn't so much fail as it just keeps trying to start prettier using npm every minute. I don't know if the same is true of other npm-based modules.

The slop machine suggests that Spotless launches using --scripts-prepend-node-path=true when using an absolute path. I tried this manually on npm 11 and 12.

For npm 11 (system npm):

# npm run start --scripts-prepend-node-path=true -- --node-server-instance-id=test1

npm warn Unknown cli config "--scripts-prepend-node-path". This will stop working in the next major version of npm.

> spotless-prettier@4.0.1 start
> node serve.js --node-server-instance-id=test1

For npm 12 (installed via maven frontend):

# ../../target/node/npm run start --scripts-prepend-node-path=true -- --node-server-instance-id=test2

npm error code EUNKNOWNCONFIG
npm error Unknown cli flag:
npm error   - --scripts-prepend-node-path
npm error Run `npm help config` for supported options.
npm error A complete log of this run can be found in: /Users/michael/.npm/_logs/2026-08-19T20_18_10_194Z-debug-0.log

So, if the slop machine is correct, that seems to explain the behavior: the option was removed in or before 11, and causes termination in 12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions