ansi-html-community
ansi-html-community copied to clipboard
Can't resolve 'ansi-html' in '.../node_modules/webpack-dev-server/client'
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.
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!
@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 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?
https://github.com/Tjatse/ansi-html/issues/19#issuecomment-1048337364
@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.