From 91c20333b83c969bc2502aa4c7b267703e07c54e Mon Sep 17 00:00:00 2001 From: volodymyr-rutskyi Date: Tue, 7 Jan 2025 15:49:28 +0200 Subject: [PATCH] fix: consider the cli install directory when resolving plugins (#1838) --- .changeset/tender-forks-argue.md | 7 +++++++ packages/core/src/config/config-resolvers.ts | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/tender-forks-argue.md diff --git a/.changeset/tender-forks-argue.md b/.changeset/tender-forks-argue.md new file mode 100644 index 000000000..cd69afa4b --- /dev/null +++ b/.changeset/tender-forks-argue.md @@ -0,0 +1,7 @@ +--- +"@redocly/openapi-core": patch +"@redocly/cli": patch +--- + +Fixed an issue where running the `preview` command failed because one of its dependencies could not be resolved. +The issue occurred when Realm was not installed in the `node_modules` of the project. diff --git a/packages/core/src/config/config-resolvers.ts b/packages/core/src/config/config-resolvers.ts index ee5136253..922e89d60 100644 --- a/packages/core/src/config/config-resolvers.ts +++ b/packages/core/src/config/config-resolvers.ts @@ -136,7 +136,14 @@ export async function resolvePlugins( const absolutePluginPath = existsSync(maybeAbsolutePluginPath) ? maybeAbsolutePluginPath : // For plugins imported from packages specifically - require.resolve(plugin, { paths: [configDir] }); + require.resolve(plugin, { + paths: [ + // Plugins imported from the node_modules in the project directory + configDir, + // Plugins imported from the node_modules in the package install directory (for example, npx cache directory) + __dirname, + ], + }); if (!pluginsCache.has(absolutePluginPath)) { let requiredPlugin: ImportedPlugin | undefined;