spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Prettier plugin can't find node executable

Open howthatdo opened this issue 2 months ago • 1 comments

I have prettier configured within a Maven spotless-maven-plugin block:

    <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.44.3</version>
        <configuration>
            <typescript>
                <includes>
                    <include>**/*.ts</include>
                </includes>
                <prettier>
                    <config>
                        <!-- ... -->
                    </config>
                </prettier>
            </typescript>
        </configuration>

When I run mvn spotless:verify, I get an error:

[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.44.3:apply (default-cli) on project my-project: Unable to format file <path-to>/some-file.ts: Can't automatically determine node executable and none was specifically supplied!
[ERROR] 
[ERROR] Spotless was unable to find a node executable.
[ERROR] Either specify the node executable explicitly or make sure it can be found next to the npm executable.

I do have node and npm installed:

% which node
/opt/homebrew/opt/node@16/bin/node
% node --version
v16.20.2
% which npm 
/opt/homebrew/opt/node@16/bin/npm
% npm --version
8.19.4

I can get around this by specifying the location of the node executable:

<prettier>
    <nodeExecutable>/opt/homebrew/opt/node@16/bin/node</nodeExecutable>
    <!-- ... -->
</prettier>

.. but that's not something I should have to do and it isn't something that will work for everyone on our team who possibly have different versions, have installed in a different path, use a different OS, etc.

If the node executable is on the system path, that's what should be used.

howthatdo avatar Oct 29 '25 13:10 howthatdo

I have the same. I've fixed it by... Switching to another formatter (I've taken gson())

Chuckame avatar Nov 11 '25 20:11 Chuckame