Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider the cli install directory when resolving plugins #1838

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/tender-forks-argue.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 8 additions & 1 deletion packages/core/src/config/config-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading