MUI installation is stuck

I had the latest working node.js which is 16.14.2 LTS. However when I tried to install material UI it threw errors.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0" from @material-ui/[email protected]
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"^4.12.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:UsersnewayAppDataLocalnpm-cacheeresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersnewayAppDataLocalnpm-cache_logs2022-04-06T00_01_01_812Z-debug-0.log

Then I downgraded node.js to 14.17.3. Material UI didn’t throw errors. However at first, it said that the "npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!"

and it was stuck at: remove:react-dev-utils: sill remove C:Usersnewaytwitter-clonenode_modulesreact-dev-utils during installation

So i exit and i tried to install again, same thing was happening and now it’s stuck at: remove:@babel/preset-env: sill remove C:Usersnewaytwitter-clonenode_modules@babelpreset-env

So I went into the package-lock.json and changed the lockfileversion from 2 to 1. It doesn’t throw the warning anymore but it’s still stuck. Another one it was stuck at is: remove:@material-ui/core: sill remove C:Usersnewaytwitter-clonenode_modules@material-uicore

How can i stop it from getting stuck during installation? Also, i’m using Visual Studio Code