I'm having truoble when I'm trying to compile my react application.
When I'm compilie the application I'm recieveing the following error:
Module not found: Can't resolve './registerServiceWorker
This is my index.js file:
import React from 'react';
import ReactDOM from 'react-dom';
import ApolloClient from "apollo-boost"
import {ApolloProvider} from "react-apollo"
import App from './App';
import registerServiceWorker from './registerServiceWorker';
const client = new ApolloClient({
uri: "http://localhost:4000"
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
registerServiceWorker();
I've used create-react-app, and I removed some not used files:
App.test.js
App.css
index.css
logo.svg
I think that this is the cause of the issue, but I can't locate the source of this issue.
Thanks in advance!
The service worker is a web API that helps you cache your assets and other files so that when the user is offline or on slow network, he/she can still see results on the screen, as such, it helps you build a better user experience, that's what you should know about service worker's for now.
I think the module should be called serviceWorker
, not registerServiceWorker
, although this depends on which version of CRA you used. The most recent version uses:
import * as serviceWorker from './serviceWorker';
and then
serviceWorker.unregister();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With