navigator.serviceWorker.getRegistrations().then((r)=>{r[0].unregister()})
The Possible Solution I have Found -
**Move your `sw.js` file out of any sub folder/directory and put it at the common or public folder.** <br>And the error would go away and the Service Worker would get easily registered.