I used the Get Started page to create a new Vaadin 14 app, after choosing the Plain Java Servlet option.
The web page successfully downloaded a .zip<
The Problem is in method
FrontendUtils::getNpmExecutable(String baseDir)
from flow-server.jar. This method tries to locate
node/node_modules/npm/bin/npm-cli.js
in $baseDir (which is project root folder in case of prepare-frontend goal). When that path does not exist, code continues executing "where/which npm.cmd" to get absolute path of 'npm.cmd'. In my case, got NodeJS installed globally, it returns correct path.
Subsequently code continues trying to execute "path-to-npm.cmd\npm.cmd -v", to ensure that npm.cmd exists and is runnable.
And here is the problem in method:
ProcessBuilder FrontEndUtils::createProcessBuilder(List
In this method under certain circumstances program code sets environment variable 'PATH' to path of npm.cmd (since ProcssBuilder.environment() returns map which does not contain 'PATH' variable).
Next when trying to execute command 'path-to-npm\npm.cmd -v', the exit value of the process is 1, and stderr is non-empty, because 'chcp' command is called before other stuff in 'npm.cmd' (probably SETLOCAL command), but since now 'chcp' is not in PATH.
Following code evaluates these conditions (exit code 1, stderr nonempty) as an error in execution of npm.cmd and
Failed to determine 'npm.cmd' tool.
message is printed.
This happens on my Windows 10, Vaadin Flow 14.0.1, NodeJS 10.16.3 installed globally.
Also got the same issues when running tomcat server with an application, since $baseDir variable contains path to tomcat bin directory.
As a workaround it is sufficient to make symbolic link of NodeJS directory into your project root (and if application running on Tomcat, also make link of NodeJS to Tomcat's bin directory).