diff --git a/core/src/main/java/io/mvnpm/esbuild/install/WebDepsInstaller.java b/core/src/main/java/io/mvnpm/esbuild/install/WebDepsInstaller.java index 9fecedc..674526e 100644 --- a/core/src/main/java/io/mvnpm/esbuild/install/WebDepsInstaller.java +++ b/core/src/main/java/io/mvnpm/esbuild/install/WebDepsInstaller.java @@ -79,6 +79,10 @@ public static boolean install(Path nodeModulesDir, List dependenc final String packageName = nameAndRoot.getKey(); final Path source = nameAndRoot.getValue(); final Path target = nodeModulesDir.resolve(packageName); + if (!Files.isDirectory(source)) { + LOG.debugf("ignored package ''%s'' probably installed through another package.json", packageName); + continue; + } dirs.add(packageName); PathUtils.deleteRecursive(target); Files.createDirectories(target.getParent()); diff --git a/core/src/main/java/io/mvnpm/esbuild/util/JarInspector.java b/core/src/main/java/io/mvnpm/esbuild/util/JarInspector.java index 7117c8c..eb29213 100644 --- a/core/src/main/java/io/mvnpm/esbuild/util/JarInspector.java +++ b/core/src/main/java/io/mvnpm/esbuild/util/JarInspector.java @@ -117,7 +117,9 @@ private static Map findPackageNameAndRootWithPackage(Path root, bo List foundFiles = searchFiles(root, PACKAGE_JSON, shouldDoMultiple); for (Path path : foundFiles) { String packageName = readPackageName(path); - paths.putIfAbsent(packageName, path.getParent()); + if (packageName != null) { + paths.putIfAbsent(packageName, path.getParent()); + } } return paths; @@ -187,6 +189,9 @@ private static String readPackageName(Properties properties) { private static String readPackageName(Path path) { try { JsonNode object = objectMapper.readTree(path.toFile()); + if (!object.has("name")) { + return null; + } return object.get("name").asText(); } catch (IOException ex) { throw new UncheckedIOException(ex);