title: FirebaseError - messaging/failed-serviceworker-registration
body: <p>Okey here is the deal, I have asked a couple of firebase related question already in Stackoverflow, and even without any answers I managed to get firebase working, and received a bunch of notifications. I really don't know what I did to make it work, it was a combination of lots of things.</p>
  
  <p>(Related issues posted earlier: <a href="https://stackoverflow.com/questions/48319660/how-to-include-firebase-cloud-messaging-into-reactjs-project-using-webpack">How to include firebase cloud messaging into ReactJS project using webpack</a> | <a href="https://stackoverflow.com/questions/48227458/firebase-fcm-with-reactjs-and-webpack-not-working-we-are-unable-to-register-the">Firebase FCM with ReactJS and Webpack not working: We are unable to register the default service worker</a>)</p>
  
  <p>Anyhow, now it is not working again. I tried to simplify some configurations etc. and I broke the service-worker.</p>
  
  <p>Now when I am trying to register the default firebase service-worker, I get the following error. When I type localhost:8000/firebase-messsaging-sw.js into my address bar, the file opens up though.</p>
  
  <p><a href="https://i.stack.imgur.com/IRKOO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IRKOO.png" alt="enter image description here"></a></p>
  
  <p>The thing that mystifies me is that "window is not defined error" since I have no idea why it is giving that. When I open up the file where it is coming from, I get this line of code:</p>
  
  <p><a href="https://i.stack.imgur.com/8KFf4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8KFf4.png" alt="line_of_code_of_the_error"></a></p>
  
  <p>Notice that I have the firebase-messaging-sw.js file running as a worker there, and opening that file opens a bunch of code, so something is registered by firebase.</p>
  
  <p>WHAT I AM ASKING IS: How do I get rid of these firebase/messaging cannot register the default service worker errors, and that window is not defined error, and get FCM running stable?</p>