Skip to content

Commit d1930d3

Browse files
authored
fix: gracefully fail when node module can't be found (#6037)
1 parent 0acfb4a commit d1930d3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/services/plugins-service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,17 @@ This framework comes from ${dependencyName} plugin, which is installed multiple
731731
): INodeModuleData {
732732
// module can be modulePath or moduleName
733733
if (!this.$fs.exists(module) || path.basename(module) !== "package.json") {
734-
module = this.getPackageJsonFilePathForModule(module, projectDir);
734+
const resolvedPath = this.getPackageJsonFilePathForModule(
735+
module,
736+
projectDir,
737+
);
738+
if (!resolvedPath) {
739+
this.$logger.warn(
740+
`Could not find module ${color.yellow(module)}. It may have been removed or is not installed. Skipping.`,
741+
);
742+
return null;
743+
}
744+
module = resolvedPath;
735745
}
736746

737747
const data = this.$fs.readJson(module);
@@ -759,7 +769,7 @@ This framework comes from ${dependencyName} plugin, which is installed multiple
759769
const nodeModules = this.getDependencies(projectData.projectDir);
760770
return _.map(nodeModules, (nodeModuleName) =>
761771
this.getNodeModuleData(nodeModuleName, projectData.projectDir),
762-
);
772+
).filter(Boolean);
763773
}
764774

765775
private async executeNpmCommand(

0 commit comments

Comments
 (0)