Recommendation:
Check out Yarn.
I was able to circumvent the issue in NPM by using Yarn instead of NPM. Yarn is basically a wrapper utility around NPM that adds extra features, which are super useful. It’s especially helpful for managing NPM dependencies better.
For instance, it can check if a package is already installed on your machine for another project, directly or as a sub dependency, and can reuse that installed version rather than re-installing a copy of the same package; saves space and makes for faster installations, especially with some of the most common dependencies.
So, due to the optimized way Yarn handles dependencies, I think it helps avoid this issue faced by the OP.
Resolution:
- First, delete the
node_modulesfolder in your project. - Yarn will complain about any
package-lock.jsonfiles, so delete that too (or back it up, then delete it). Do not deletepackage.json, yarn will need that. - Simply install yarn:
npm i yarn(you could do this globally, too). - Then run
yarn installin your project directory.