reactjsurlwebpackdeploying

Getting `Cannot find module 'url'` after deploying react app to production


I have developed one react app from scratch by creating using create-react-app, and it is working well on my local env. But after deploying to production, I am getting Cannot find module 'url' error when trying to see all pages on the browser. So I added 'url' to package.json, but still getting the same error.


Solution

  • I don't think this is the best solution for this issue, but I think my solution will be helpful. My issue was coming from URLSearchParams class in my codebase. I have used useParams instead of using it and removed it from my codebase, and then my deploying to production was done successfully.