Assertion Error : App Version has already been registered

Im using ember to develop a project. Please help me with this error. Im unable to run my project on local. After hitting ember server the build is successful. But on hitting the http://localhost:4200 Loads empty page with console error.

Uncaught Error: Assertion Failed: The initializer 'App Version' has already been registered
    at assert (index.js:172)
    at Function.initializer (index.js:420)
    at registerInitializers (index.js:27)
    at loadInitializers (index.js:68)
    at Module.callback (app.js:25)
    at Module.exports (loader.js:106)
    at requireModule (loader.js:27)
    at app-boot.js:3

Unable to understand what to do. Any help regarding this would be appreciated.

Hi and welcome.

Have you customized the contents of index.html at all?

What custom stuff is in ember-cli-build.js?

I have added bootstrap addon for ember. My ember-cli-build.js looks like this

 'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    'ember-bootstrap': {
      'bootstrapVersion': 4,
      'importBootstrapCSS': false
    }
  });

My index.html looks like this

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>CashNApp</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1"> {{content-for "head"}}
    <link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://maxst.icons8.com/vue-static/landings/line-awesome/font-awesome-line-awesome/css/all.min.css">
    <link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
    <link integrity="" rel="stylesheet" href="{{rootURL}}assets/cash-n-app.css"> {{content-for "head-footer"}}
</head>

<body>
    {{content-for "body"}}

    <script src="{{rootURL}}assets/vendor.js"></script>
    <script src="{{rootURL}}assets/cash-n-app.js"></script>

    {{content-for "body-footer"}}
</body>

</html>

When I first found this issue, Running npm install solved this. But now, again the issue resurfaced and npm install does not seem to solve this issue.

Hmm, everything looks normal there.

To debug this further, I would put a breakpoint at the place in loadInitializers that’s mentioned in the stack trace, to answer: does loadInitializers run more than once? And if so, who is calling it?

Also, if it only runs once, what is in the list of initializers it’s trying to run. Does the list have duplicates? If yes, hunt down where they’re coming from.

Hey @ef4 I checked as you mentioned. The list of initializers contains duplicates.

Kindly check the screenshot. Also would be great if you can suggest me what all things I need to look for to eradicate this duplication.

Look inside dist/assets/your-app-name.js. Do both of these appear?

define("cash-n-app/initializers/app-version"

define("cash-n-app/initializers/app-version 2"

If yes, the problem is somewhere in the build pipeline, if no, there’s something in the code that loads initializers.

I’m not aware of anything in the build pipeline that appends numbers to module names like this, it’s very weird.