Hi shirisha pallepati
Make sure to update your node version as follows:
node -v v16.9.1
npm --version 8.1.3
if you are using Yoeman to create your react widget, I prefer you update mendix/pluggable-widgets-tools from 9.0.0v to 9.7.0v, you can just update it manually by changing the value in package.json and do npm i again.
by doing so you will get almost the latest version and it will allow you to install any package you would like to use, but note that some npm packages wont work as they are from community so it wont be compatible with Yoeman generator.
doing so solved 95% of any npm installation I wanted before. Happy Hacking