Failed to compile. ./src/registerServiceWorker.js

#1

I just started setting up my work environment, it seems like there’s an issue in my registerServiceWorker.js file and I can’t seem to find a way to fix it. Any suggestion?

Failed to compile.

./src/registerServiceWorker.js
  Line 12:    Expected indentation of 2 spaces but found 1                                         indent
  Line 12:    'window' is not defined                                                              no-undef
  Line 12:   '||' should be placed at the beginning of the line                                   operator-linebreak
  Line 14:    'window' is not defined                                                              no-undef
  Line 14:   '||' should be placed at the beginning of the line                                   operator-linebreak
  Line 16:    'window' is not defined                                                              no-undef
  Line 17:    Expected indentation of 3 spaces but found 2                                         indent
  Line 17:   Missing trailing comma                                                               comma-dangle
  Line 18:    Missing trailing comma                                                               comma-dangle
  Line 22:    Expected indentation of 2 spaces but found 1                                         indent
  Line 22:   'navigator' is not defined                                                           no-undef
  Line 24:    Expected indentation of 4 spaces but found 2                                         indent
  Line 24:   'window' is not defined                                                              no-undef
  Line 25:    Expected indentation of 4 spaces but found 2                                         indent
  Line 25:   'window' is not defined                                                              no-undef
  Line 26:    Expected indentation of 6 spaces but found 3                                         indent
  Line 27:    Expected indentation of 6 spaces but found 3                                         indent
  Line 28:    Expected indentation of 6 spaces but found 3                                         indent
  Line 29:    Expected indentation of 6 spaces but found 3                                         indent
  Line 30:    Expected indentation of 4 spaces but found 2                                         indent
  Line 32:    Expected indentation of 4 spaces but found 2                                         indent
  Line 32:    'window' is not defined                                                              no-undef
  Line 33:    Expected indentation of 6 spaces but found 3                                         indent
  Line 35:    Expected indentation of 6 spaces but found 3                                         indent
  Line 36:    Expected indentation of 8 spaces but found 4                                         indent
  Line 37:    Expected indentation of 8 spaces but found 4                                         indent
  Line 37:    'checkValidServiceWorker' was used before it was defined                             no-use-before-define
  Line 39:    Expected indentation of 8 spaces but found 4                                         indent
  Line 40:    Expected indentation of 8 spaces but found 4                                         indent
  Line 41:    Expected indentation of 8 spaces but found 4                                         indent
  Line 41:    'navigator' is not defined                                                           no-undef
  Line 42:    Expected indentation of 10 spaces but found 5                                        indent
  Line 43:    Expected indentation of 12 spaces but found 6                                        indent
  Line 43:   '+' should be placed at the beginning of the line                                    operator-linebreak
  Line 44:   Missing trailing comma                                                               comma-dangle
  Line 45:    Expected indentation of 10 spaces but found 5                                        indent
  Line 46:    Expected indentation of 8 spaces but found 4                                         indent
  Line 47:    Expected indentation of 6 spaces but found 3                                         indent
  Line 48:    Expected indentation of 8 spaces but found 4                                         indent
  Line 49:    Expected indentation of 8 spaces but found 4                                         indent
  Line 49:    'registerValidSW' was used before it was defined                                     no-use-before-define
  Line 50:    Expected indentation of 6 spaces but found 3                                         indent
  Line 51:    Expected indentation of 4 spaces but found 2                                         indent
  Line 52:    Expected indentation of 2 spaces but found 1                                         indent
  Line 56:    Expected indentation of 2 spaces but found 1                                         indent
  Line 56:    'navigator' is not defined                                                           no-undef
  Line 57:    Expected indentation of 4 spaces but found 2                                         indent
  Line 58:    Expected indentation of 4 spaces but found 2                                         indent
  Line 58:    Expected parentheses around arrow function argument having a body with curly braces  arrow-parens
  Line 59:    Expected indentation of 6 spaces but found 3                                         indent
  Line 59:    Assignment to property of function parameter 'registration'                          no-param-reassign
  Line 60:    Expected indentation of 8 spaces but found 4                                         indent
  Line 61:    Expected indentation of 8 spaces but found 4                                         indent
  Line 62:    Expected indentation of 10 spaces but found 5                                        indent
  Line 63:    Expected indentation of 12 spaces but found 6                                        indent
  Line 63:   'navigator' is not defined                                                           no-undef
  Line 64:    Expected indentation of 14 spaces but found 7                                        indent
  Line 65:    Expected indentation of 14 spaces but found 7                                        indent
  Line 66:    Expected indentation of 14 spaces but found 7                                        indent
  Line 67:    Expected indentation of 14 spaces but found 7                                        indent
  Line 68:    Expected indentation of 14 spaces but found 7                                        indent
  Line 69:    Expected indentation of 12 spaces but found 6                                        indent
  Line 70:    Expected indentation of 14 spaces but found 7                                        indent
  Line 71:    Expected indentation of 14 spaces but found 7                                        indent
  Line 72:    Expected indentation of 14 spaces but found 7                                        indent
  Line 73:    Expected indentation of 14 spaces but found 7                                        indent
  Line 74:    Expected indentation of 12 spaces but found 6                                        indent
  Line 75:    Expected indentation of 10 spaces but found 5                                        indent
  Line 76:    Expected indentation of 8 spaces but found 4                                         indent
  Line 77:    Expected indentation of 6 spaces but found 3                                         indent
  Line 78:    Expected indentation of 4 spaces but found 2                                         indent
  Line 79:    Expected indentation of 4 spaces but found 2                                         indent
  Line 79:   Expected parentheses around arrow function argument having a body with curly braces  arrow-parens
  Line 80:    Expected indentation of 6 spaces but found 3                                         indent
  Line 81:    Expected indentation of 4 spaces but found 2                                         indent
  Line 85:    Expected indentation of 2 spaces but found 1                                         indent
  Line 86:    Expected indentation of 2 spaces but found 1                                         indent
  Line 86:    'fetch' is not defined                                                               no-undef
  Line 87:    Expected indentation of 4 spaces but found 2                                         indent
  Line 87:    Expected parentheses around arrow function argument having a body with curly braces  arrow-parens
  Line 88:    Expected indentation of 6 spaces but found 3                                         indent
  Line 89:    Expected indentation of 6 spaces but found 3                                         indent
  Line 90:    Expected indentation of 8 spaces but found 4                                         indent
  Line 90:   '||' should be placed at the beginning of the line                                   operator-linebreak
  Line 92:    Expected indentation of 6 spaces but found 3                                         indent
  Line 93:    Expected indentation of 8 spaces but found 4                                         indent
  Line 94:    Expected indentation of 8 spaces but found 4                                         indent
  Line 94:    'navigator' is not defined                                                           no-undef
  Line 94:   Expected parentheses around arrow function argument having a body with curly braces  arrow-parens
  Line 95:    Expected indentation of 10 spaces but found 5                                        indent
  Line 96:    Expected indentation of 12 spaces but found 6                                        indent
  Line 96:    'window' is not defined                                                              no-undef
  Line 97:    Expected indentation of 10 spaces but found 5                                        indent
  Line 98:    Expected indentation of 8 spaces but found 4                                         indent
  Line 99:    Expected indentation of 6 spaces but found 3                                         indent
  Line 100:   Expected indentation of 8 spaces but found 4                                         indent
  Line 101:   Expected indentation of 8 spaces but found 4                                         indent
  Line 102:   Expected indentation of 6 spaces but found 3                                         indent
  Line 103:   Expected indentation of 4 spaces but found 2                                         indent
  Line 104:   Expected indentation of 4 spaces but found 2                                         indent
  Line 105:   Expected indentation of 6 spaces but found 3                                         indent
  Line 106:   Expected indentation of 8 spaces but found 4                                         indent
  Line 106:  Missing trailing comma                                                               comma-dangle
  Line 107:   Expected indentation of 6 spaces but found 3                                         indent
  Line 108:   Expected indentation of 4 spaces but found 2                                         indent
  Line 112:   Expected indentation of 2 spaces but found 1                                         indent
  Line 112:  'navigator' is not defined                                                           no-undef
  Line 113:   Expected indentation of 4 spaces but found 2                                         indent
  Line 113:   'navigator' is not defined                                                           no-undef
  Line 113:  Expected parentheses around arrow function argument having a body with curly braces  arrow-parens
  Line 114:   Expected indentation of 6 spaces but found 3                                         indent
  Line 115:   Expected indentation of 4 spaces but found 2                                         indent
  Line 116:   Expected indentation of 2 spaces but found 1                                         indent

Search for the keywords to learn more about each error.
URIError: Failed to decode param '/%PUBLIC_URL%/bootstrap.css'
    at decodeURIComponent (<anonymous>)
    at decode_param (/Users/Theelooper/Desktop/animal-kingdom-master/node_modules/express/lib/router/layer.js:172:12)

The registerServiceWorker file code:
// In production, we register a service worker to serve assets from local cache.

// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.

// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.

const isLocalhost = Boolean(
  window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
  /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);

export default function register() {
  if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) {
  // Our service worker won't work if PUBLIC_URL is on a different origin
  // from what our page is served on. This might happen if a CDN is used to
  // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
  return;
}

window.addEventListener('load', () => {
  const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;

  if (isLocalhost) {
    // This is running on localhost. Lets check if a service worker still exists or not.
    checkValidServiceWorker(swUrl);

    // Add some additional logging to localhost, pointing developers to the
    // service worker/PWA documentation.
    navigator.serviceWorker.ready.then(() => {
      console.log(
        'This web app is being served cache-first by a service ' +
          'worker. To learn more, visit https://goo.gl/SC7cgQ'
      );
    });
  } else {
    // Is not local host. Just register service worker
    registerValidSW(swUrl);
  }
});
  }
}

function registerValidSW(swUrl) {
  navigator.serviceWorker
.register(swUrl)
.then(registration => {
  registration.onupdatefound = () => {
    const installingWorker = registration.installing;
    installingWorker.onstatechange = () => {
      if (installingWorker.state === 'installed') {
        if (navigator.serviceWorker.controller) {
          // At this point, the old content will have been purged and
          // the fresh content will have been added to the cache.
          // It's the perfect time to display a "New content is
          // available; please refresh." message in your web app.
          console.log('New content is available; please refresh.');
        } else {
          // At this point, everything has been precached.
          // It's the perfect time to display a
          // "Content is cached for offline use." message.
          console.log('Content is cached for offline use.');
        }
      }
    };
  };
})
.catch(error => {
  console.error('Error during service worker registration:', error);
});
}

function checkValidServiceWorker(swUrl) {
  // Check if the service worker can be found. If it can't reload the page.
  fetch(swUrl)
.then(response => {
  // Ensure service worker exists, and that we really are getting a JS file.
  if (
    response.status === 404 ||
    response.headers.get('content-type').indexOf('javascript') === -1
  ) {
    // No service worker found. Probably a different app. Reload the page.
    navigator.serviceWorker.ready.then(registration => {
      registration.unregister().then(() => {
        window.location.reload();
      });
    });
  } else {
    // Service worker found. Proceed as normal.
    registerValidSW(swUrl);
  }
})
.catch(() => {
  console.log(
    'No internet connection found. App is running in offline mode.'
  );
});
}

export function unregister() {
  if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
  registration.unregister();
});
  }
}
#2

That indicates that you are running the animal kingdom from local file or so. You need to use the deploy directory