-
Notifications
You must be signed in to change notification settings - Fork 80
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
Getting Error: Cannot find module 'docusaurus-plugin-openapi' when trying to use as plugin #78
Comments
If you are using both the preset and the plugin, you may need to have both of them installed. However, It shouldn’t be strictly necessary, because installing the preset should also install the plugin and the theme. It may be helpful to delete node_modules / any lockfile and try to reinstall. You can also check out the demo folder of this project for a working example of using multiple instances of the plugin.
Using the preset is just a convenience and not a requirement. In order to use the plugin without the preset, you will need to install the plugin and the theme. The plugin usage will be exactly the same as shown in your current config, however you will also need to add a |
This shouldn't be causing the error you are seeing but I think your plugin config: ["docusaurus-plugin-openapi", {
id: "kiosk_rest_api",
path: "rest-api-kiosk",
openapiPath: "./rest_api_kiosk.json",
proxy: {
"/proxy": {
target: "http://localhost:8091",
pathRewrite: { "^/proxy": "" }
}
}
}], should look like this: ["docusaurus-plugin-openapi", {
id: "kiosk_rest_api",
path: "./rest_api_kiosk.json",
routeBasePath: "rest-api-kiosk",
// I'm also not sure what the does?
proxy: {
"/proxy": {
target: "http://localhost:8091",
pathRewrite: { "^/proxy": "" }
}
}
}], |
Thank you @bourdakos1 Changing the plugin definition to: ["docusaurus-plugin-openapi", {
id: "kiosk_rest_api",
path: "./rest_api_kiosk.json",
routeBasePath: "rest-api-kiosk",
//proxy: {
// "/proxy": {
// target: "http://localhost:8091",
// pathRewrite: { "^/proxy": "" }
// }
//}
}], Solves the error. Now, this part: proxy: {
"/proxy": {
target: "http://localhost:8091",
pathRewrite: { "^/proxy": "" }
}
} I have seen on the video: https://www.youtube.com/watch?v=-Z9Zn8RHf0c&t=15s If I put: ["docusaurus-plugin-openapi", {
id: "kiosk_rest_api",
path: "./rest_api_kiosk.json",
routeBasePath: "rest-api-kiosk",
proxy: {
"/proxy": {
target: "http://localhost:8091",
pathRewrite: { "^/proxy": "" }
}
}
}], I have the error:
This worked on docusaurus-plugin-openapi 1.x |
Maybe |
@Anthony-Gaudino It looks like at one point docusaurus would pass devServer configs (which includes proxy) to Webpack, but it looks like they don't support that anymore. I would open an issue on docusaurus if this is a functionality you need. |
Hi @bourdakos1, Sorry for late reply.
Removing
I have been using By the way, the most recent Docusarus version now is |
0.2.0 adds validation that checks that the options passed are valid. Proxy isn’t a valid option so it throws an error now. In beta 9 plugin 0.1.1, it doesn’t throw an error, but it won’t actually start a proxy. |
@bourdakos1 In recent versions (beta.9, iirc) we have upgraded the dev server to v4. I'm actually not aware that plugins can configure the dev server itself, but we didn't remove any plugin lifecycle. |
@Josh-Cena This plugin never explicitly had support for this I don't think As a proof-of-concept, I attempted to add the following to the devServer: {
proxy: {
"/proxy": {
target: "http://localhost:8091",
pathRewrite: { "^/proxy": "" },
},
},
} However, this didn't seem to have an effect. It looks like at one point |
Oh wow, neither was I aware about |
Should be fixed in facebook/docusaurus#6107 and you will be able to write: function ProxyPlugin(context) {
return {
name: 'proxy-plugin',
configureWebpack() {
return {
devServer: {
proxy: {
'/hey': {
target: 'https://google.com',
pathRewrite: {'^/hey': ''},
},
},
},
};
},
};
} However, I don't understand how this proxy option used to work with this plugin. |
Awesome, thanks!
I'm just as confused as you are haha |
I'm following the instructions to update to 0.2.2. I installed
docusaurus-preset-openapi
and uninstalleddocusaurus-plugin-openapi
as I understood thatdocusaurus-preset-openapi
already includes the plugin.Just using the preset it works, but when I try to have multiple OpenApi definitions where I need to add a plugin entry I get an
Error: Cannot find module 'docusaurus-plugin-openapi'
.My package.json:
My docusaurus.config.js
Also, Is it possible to use just multiple plugins and skip using the
docusaurus-preset-openapi
preset?The text was updated successfully, but these errors were encountered: