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

Can't resolve 'ansi-html' in '.../node_modules/webpack-dev-server/client' #10

Open
avinashs2401 opened this issue Mar 16, 2022 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@avinashs2401
Copy link

avinashs2401 commented Mar 16, 2022

Hi,
In my angular application I faced the ansi-html vulnerability issue (No direct dependency of ansi-html in my project, it's an inner dependency of other packages) and I did the following in package.json to force resolve to ansi-html-community,

"resolutions": {
    "ansi-html": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz"
}
 "scripts": {
    "preinstall": "npx npm-force-resolutions"
  }

The package-lock.json now has the ansi-html-community only and not ansi-html. But when I run the application, I get the following error,

Error: (webpack)-dev-server/client/overlay.js
Module not found: Error: Can't resolve 'ansi-html' in '..../node_modules/webpack-dev-server/client'

Please help on this.

@mahdyar
Copy link
Owner

mahdyar commented Mar 16, 2022

Hi @avinashs2401, did you change the import as well? you should import it like this:

import ansiHTML from "ansi-html-community";

Read more here.

Let me know if it's solved or not!

@avinashs2401
Copy link
Author

@mahdyar I'm not using the ansiHtml explicitly anywhere in my project. It's an inner dependency of webpack-dev-server which in turn is a dependency of @angular-devkit/build-angular

@mahdyar
Copy link
Owner

mahdyar commented Mar 17, 2022

@mahdyar I'm not using the ansiHtml explicitly anywhere in my project. It's an inner dependency of webpack-dev-server which in turn is a dependency of @angular-devkit/build-angular

Would you try with overrides to see if it works?
Tjatse#19 (comment)

@avinashs2401
Copy link
Author

@mahdyar No. That's not working as well. So the problem I'm facing is exactly described here by someone - https://stackoverflow.com/questions/64605805/npm-force-resolutions-not-working-when-installing-a-new-package. Initially when I delete node_modules and run npm install. There is no trace of ansi-html in the resolved packages. But when I run the application I face the error described above.
Again, when I simply give another npm install (maybe for installing a new package (or) just simply one more npm install without any change), ansi-html 0.0.7 comes into play as one of the dependencies in webpack-dev-server and the "resolutions" or "overrides" in package.json is not taken into account. But this time the application runs without issues as its able to find ansi-html.

@mahdyar mahdyar added the help wanted Extra attention is needed label Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants