diff --git a/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java b/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java index 875d5c84d59..5c43237003b 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java @@ -302,19 +302,24 @@ private JsonObject readGeneratedDevDependencies(String path) } private boolean shouldRunNpmInstall() { - if (packageUpdater.nodeModulesFolder.isDirectory()) { - // Ignore .bin and pnpm folders as those are always installed for - // pnpm execution - File[] installedPackages = packageUpdater.nodeModulesFolder - .listFiles( - (dir, name) -> !ignoredNodeFolders.contains(name)); - assert installedPackages != null; - return installedPackages.length == 0 - || (installedPackages.length == 1 && FLOW_NPM_PACKAGE_NAME - .startsWith(installedPackages[0].getName())) - || (installedPackages.length > 0 && isVaadinHashUpdated()); + if (!packageUpdater.nodeModulesFolder.isDirectory()) { + return true; + } + // Ignore .bin and pnpm folders as those are always installed for + // pnpm execution + File[] installedPackages = packageUpdater.nodeModulesFolder + .listFiles((dir, name) -> !ignoredNodeFolders.contains(name)); + assert installedPackages != null; + if (installedPackages.length == 0) { + // Nothing installed + return true; + } else if (installedPackages.length == 1 && FLOW_NPM_PACKAGE_NAME + .startsWith(installedPackages[0].getName())) { + // Only flow-frontend installed + return true; + } else { + return isVaadinHashUpdated(); } - return true; } private boolean isVaadinHashUpdated() {