How does the command work "npm set config registry"

I’ve been looking for a while to download dependencies from npm for my react project. However, every time I run I get the error:

npm ERR! syscall getaddrinfo
npm ERR! errno ENOTFOUND
npm ERR! network request to failed, reason: getaddrinfo ENOTFOUND your-proxy-url
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Local\npm-cache\_logs\2022-06-20T16_18_22_664Z-debug.log

To solve the problem I used the command npm clear cache --force then npm clean cache --force then npm i react-dom --force because react-dom is one of the packages I don’t couldn’t install. After using the command npm set config registry it worked but a few tens of minutes later I had the same problem, I reused the command that worked mentioned above but without success, after retrying this same command several times later multiple failures, I was able to install a package again. I don’t use a proxy and even when I disabled my firewall I still had the same problem. On the forums I was told to use the command npm set config registry what I don’t understand is why this command works then stops working directly and does not work after more than ten tries. Is it because of my computer, where that’s how it works.