-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Why does installing swagger-ui require Visual Studio and a C++ toolchain? #9001
Comments
From what I see, you're using pnpm. I'm not sure how it handles I'll explain how the SwaggerUI@5 works with npm. SwaggerUI@5 is using swagger-client which under the hood uses ApiDOM to facilitate OpenAPI 3.1.0 definition resolution. Number of dependencies of ApiDOM are marked as optional like (tree-sitter), and if they fail to install, SwaggerUI will work just fine without them. If optional dependencies fail to install, in More info in: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#optionaldependencies |
@char0n Ah, this is very helpful, thank you! I'll raise an issue with pnpm. |
I'm using yarn and it also produces very ugly logs, and it does this with any package installation or removal. Please fix this if possible. I use swagger-ui in some of my packages that are published on npmjs.com and every user sees these logs: yarn logs
|
I don't think every user would
You need to install ps. you can stop post install hooks from running with I note there are prebuilt binaries on github for tree-sitter anyway https:/tree-sitter/tree-sitter/releases/tag/v0.20.8 so there isn't necessarily a need for these to built on the end users computer, tree-sitter could allow these to be fetched from github on install time (there is a prebuildify plugin for that) but that won't work with Hope that helps a bit :) |
@YOU54F, yes, but no. I'm running Ubuntu 22.04 and only install the programs I need as a TypeScript web developer. I understand that I can install |
It's a known documented thing in the node ecosystem for packages that require native modules. See electrons docs https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules |
I'd argue with your stats personally, it's a thing in the javascript ecosystem. it's not overly common, but considering your a ts web developer, I assume you've worked with electron. https://nodejs.org/api/addons.html https://blog.risingstack.com/writing-native-node-js-modules/ |
ps. I also help maintain pact-js, we prebuild our native modules (we leverage rust code via a shared library to extend the power of our JS code) - we used to require our users to build these, but it did cause issues for a small percentage. It was enough for me to prebuild and package the native modules into the npm package (but it inflated the package size) - it's all a set of trade-offs :( |
Hi @KostyaTretyak, We've invested considerable amount of time to solve this so that we don't see any ugly long error logs. In latest versions of If you don't want to see those error in your project there is a simple solution documented in swagger-client documentation: https:/swagger-api/swagger-js/blob/master/docs/usage/installation.md#installation In yarn, selective dependency resolutions works in the same way. Inside your README file, in installation instructions sections, you'll suggest people to do the Another way to remedy this is to disassemble the https:/swagger-api/apidom/tree/main/packages/apidom-reference package (used by swagger-client/swagger-ui and causing these failed install errors) into many more packages, and then assemble those new packages back to use-case based packages, one of which will be for swagger-ui usecase, which doesn't actually need IMHO concept of If you have any suggestions, I'm trilled to hear them, as unfortunately I've run out of new ideas, except for the idea of disassembling the |
@char0n, first of all, thank you for taking the time to answer me, even when I ask questions in closed issues.
I tried it, but for some reason it doesn't work: "resolutions": {
"@swagger-api/apidom-reference/@swagger-api/apidom-ns-asyncapi-2": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-api-design-systems-json": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-asyncapi-json-2": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-json": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-openapi-json-3-0": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-openapi-json-3-1": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "yarn:[email protected]",
"@swagger-api/apidom-reference/@swagger-api/apidom-parser-adapter-yaml-1-2": "yarn:[email protected]"
} And this doesn't work: "resolutions": {
"@swagger-api/apidom-ns-asyncapi-2": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-api-design-systems-json": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-asyncapi-json-2": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-json": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-3-0": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-3-1": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "yarn:[email protected]",
"@swagger-api/apidom-parser-adapter-yaml-1-2": "yarn:[email protected]"
} And with |
@KostyaTretyak I'm not sure about Anyway this overrides/resolutions are meant for your downstream consumers (people using your package). They need to use this override to get rid of the errors. If you put in inside your package, it has no effect downstream. |
Please tell me which version of |
These optional dependencies come from https:/swagger-api/apidom and https://www.npmjs.com/package/swagger-client respectively. If you're fixated to remove the errors from you package, you https://www.npmjs.com/package/swagger-ui-dist which contains build fragments of already pre-built SwaggerU and doesn't install anything. Here is a documentation of what each fragment is: #7831 (comment) |
For me adding it like this to package.json removed the error from logs. (I'm using yarn) "resolutions": {
"@swagger-api/apidom-ns-asyncapi-2": "npm:[email protected]",
"@swagger-api/apidom-ns-openapi-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-api-design-systems-json": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-asyncapi-json-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-json": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-3-0": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-3-1": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-workflows-json-1": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-workflows-yaml-1": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-yaml-1-2": "npm:[email protected]"
}``` |
Q&A (please complete the following information)
Describe the bug you're encountering
I can't install this dependency because it requires Visual C++. Why on earth does a simple UI library require GBs of C++ tools to be installed?
The text was updated successfully, but these errors were encountered: