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

Cannot find module querystring-browser #7556

Closed
benjdlambert opened this issue Oct 14, 2021 · 11 comments
Closed

Cannot find module querystring-browser #7556

benjdlambert opened this issue Oct 14, 2021 · 11 comments

Comments

@benjdlambert
Copy link

Q&A (please complete the following information)

  • OS: [e.g. macOS]
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]
  • Method of installation: [e.g. npm, dist assets] yarn
  • Swagger-UI version: [e.g. 3.10.0] - 4.0.0rc
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]

Content & configuration

Module not found: Error: Can't resolve 'querystring-browser' in '/tmp/backstage-e2e-fvJBjP/test-app/node_modules/swagger-ui-react'

Looks like due to the 3.17.0 release of swagger-client which removed the querystring-browser dependency, this module fails to build with the latest stuff.

Had to force to use the older 3.16.0 of swagger-client to get this to work.

@benjdlambert benjdlambert changed the title Cannot find module ` Cannot find module querystring-browser Oct 14, 2021
@robertgorecki
Copy link

+1, same problem here, error "Cannot find module: 'querystring-browser'. Make sure this package is installed." with "swagger-ui-react@3.52.4"

@mathis-m
Copy link
Contributor

@char0n have a look at this! Probably due to the buffer PR.

@paztis
Copy link

paztis commented Oct 14, 2021

swagger-ui-react has no dependency to querystring-browser
it has a nested dependency to it through swagger-client, but swagger client jt remove it few days ago

@mathis-m
Copy link
Contributor

Ref swagger-api/swagger-js#2288

@robertgorecki
Copy link

Seems to be fixed now with "swagger-ui-react@3.52.5" where dependency on "swagger-client" was upgraded.

@char0n
Copy link
Member

char0n commented Oct 15, 2021

Hello all,

This is a repeated problem between swagger-ui and swagger-client. It happens whenever we remove some library from swagger-client. The primary cause of this is the way how we create release fragments with webpack for swagger-ui. We plan to remedy this in near future.

For now, please update to the latest version of swagger-ui: swagger-ui@3.52.5 or swagger-ui@4.0.0-rc.4 which makes this problem go away. If you cannot update for any reason, pin the swagger-client to any version before 3.17.0 as suggested in issue description.

@kaiyoma
Copy link

kaiyoma commented Oct 19, 2021

I'm seeing a much more serious version of this problem, even after upgrading to 3.52.5. That version does indeed fix the issues with querystring-browser, but there are still about half a dozen more dependencies with the same issue.

To repro:

  1. Start with a webpack project that uses swagger-ui-react
  2. Use pnpm link to link an external package (the package doesn't even have to be related to swagger)
  3. Start the webpack dev server

At this point, I get a bunch of errors about missing packages. These errors don't appear when I don't use the linking mechanism. Here's what I'm seeing:

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'autolinker' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'btoa' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'fast-json-patch' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'formdata-node' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'isarray' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'qs' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

ERROR in ./node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react/swagger-ui.js
Module not found: Error: Can't resolve 'traverse' in '.../node_modules/.pnpm/swagger-ui-react@3.52.5_react-dom@16.14.0+react@16.14.0/node_modules/swagger-ui-react'

It would appear that the following are not being set up correctly as dependencies:

  1. autolinker
  2. btoa
  3. fast-json-patch
  4. formdata-node
  5. isarray
  6. qs
  7. traverse

@char0n
Copy link
Member

char0n commented Oct 20, 2021

Hi @kaiyoma,

First thing I've noticed is that you're using pnpm. Unfortunately we don't test against it and we have no idea how swagger-ui-react behaves when installed via pnpm. We recomment to use standard npm.

I thus cannot reproduce errors that you're seeing. I've put together a repository with minimal webpack@5 setup using swagger-ui-react and I was able to compile successfully without any errors.

Repo: https://github.com/char0n/minimal-react-webpack-babel-setup

Repo uses swagger-ui-react@3.52.5 which comes with swagger-client@3.17.0. Everything compiles without errors and works as expected.

I assume you might have problems with your local setup.

@char0n
Copy link
Member

char0n commented Nov 5, 2021

Closing this for now. If any additional problems arise, please reopen.

@char0n char0n closed this as completed Nov 5, 2021
@JeremyKennedy
Copy link

I can confirm that the 7 missing dependencies mentioned above are an issue when using the PnP feature of Yarn 2. I was able to fix it by repeatedly running yarn add with the dependencies reported as missing.

@kaiyoma
Copy link

kaiyoma commented Dec 14, 2021

Sounds like something about swagger doesn't work correctly with next-generation package managers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants