I had the same error. I was able to fix it (after a lot of effort) by minimizing the differences in the package.json dependencies when compared to the original streamlit-component-template. I suggest to copy the dependencies from Streamlit’s package.json to your own project to start.
The offending package is react-scripts. There is a related issue: https://github.com/streamlit/component-template/issues/23. All you need is downgrading react-scripts in package.json to version 4.0.1 (any other 4.x.x will probably do the job as well.).