8
votes

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!

1
Can you show your folder structure? - Colin Ricardo

1 Answers

9
votes

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();