Ember UI not loading

Ember UI is not loading on staging env with below error message in the console

vendor-fc7ff223306b879e26e5fb5c6862cc79.js:2693 Uncaught TypeError: e.indexOf is not a function
    at De (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:2693)
    at n.property (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:2709)
    at Le (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:2727)
    at vendor-fc7ff223306b879e26e5fb5c6862cc79.js:4507
    at Array.reduce (<anonymous>)
    at s.callback (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:4507)
    at s.exports (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:18)
    at s._reify (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:21)
    at s.reify (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:20)
    at s.exports (vendor-fc7ff223306b879e26e5fb5c6862cc79.js:17)

I am clueless what could cause this and it not reproducible locally.

Any help would be appreciated please.

Hmm, it may be hard to say what’s happening from the error message.

What I might try first:

  • Open vendor-fc7ff223306b879e26e5fb5c6862cc79.js in a text editor (not sure if the file exists somewhere)
  • Search for indexOf in your Ember project’s app folder (perhaps there’s a reduce somewhere nearby? e.indexOf sounds like the line of code may exist in a try-catch statement)

@ijlee2 Here is the portion of the code you were talking about

var Me = /\.@each$/
        function De(e, t) {
            var n = e.indexOf("{")
            n < 0 ? t(e.replace(Me, ".[]")) : function e(t, n, r, i) {
                var o = n.indexOf("}")
                  , s = 0
                  , a = void 0
                  , l = void 0
                var u = n.substring(r + 1, o).split(",")
                var c = n.substring(o + 1)
                t += n.substring(0, r)
                l = u.length
                for (; s < l; )
                    (a = c.indexOf("{")) < 0 ? i((t + u[s++] + c).replace(Me, ".[]")) : e(t + u[s++], c, a, i)
            }("", e, n, t)
        }

It is auto generated right?

Thanks for trying out the suggestion and sharing the output code. Yes, I think it’s auto-generated.

I think the next step is to somehow not minify (I hope that’s the right term to use) the code so that we can better understand who created this code and who’s calling it.

I’m not sure how to do so, though. Let me post the link to this thread on Discord in case someone there can help. :slightly_smiling_face:

1 Like

Sure, Thank you for that. I think it is getting generated when we execute ember build -prod

Try to see if you have the same problem when you use a newer version of Node in combination with the right NPM / Yarn version.

I had a problem of a syntax error generated in one of my vendor packages I relied on. So, what I did was, use the NVM package to upgrade your node + npm version, in my case from node 8 to node 10.

$ nvm install 10.20.1 # This will install the right npm
$ rm -rf node_modules/ # remove the packages.
$ npm install # install the fresh ones.

Judging from the code though, I see that this packages is used, based on the debug trace, reify - npm. Investigate how that package is used within the build, see if depends on different versions of Ember / Node, or is it maybe used in an Ember version under the hood? This is at least a lead to follow in your debugging session.

–EDIT– I see that it is used in Babel 2015, which is used in some Ember version you are using, which depends on a specific node version / npm version. My guess is that if you have this right, and you’ve matched the right versions of your dependencies within your package.json with the ember-cli version you are using, it’s gonna give some results.

See here the dependents of reify:

Particularly, check that in your package.json

“ember-cli-babel”:“matches with your ember-cli version”

You can use ember-cli-diff with two versions two get a nice change list of dependencies https://www.ember-cli-diff.org/

I am using Node Version: v12.18.3 locally. And 8.10.* in the server

"ember-cli": "~3.5.1",
"ember-cli-app-version": "^3.2.0",
"ember-cli-babel": "^6.16.0",

Will this cause the issue?

@Sahil_Paudel This will most definitely be the problem if you build the production build on the server. I’d say, straighten out the node versions. You should use Node v10 for Ember 3.5.1.

See:

Remember that not all versions of software work together always. That’s true everywhere and most certainly for JS frameworks to work and build correctly.

2 Likes

@IcyRizard Just out of curosity it was working just fine week before and also it is working fine in production (though we haven’t build it since ages).

It might be possible the latest build changed something?

@Sahil_Paudel It could happen that there was one package in your dependencies that is different, or the dependencies of your dependencies… etc. that was updated. If you can compare your package-lock.json with the one that was working, maybe you can find the reason.

Oh wait, it was in reify, so maybe that was updated in the meanwhile, and seems to be incompatible with node v12.*

Incompatible node versions are often the reason when building is not working. At that moment, node programs are running that crunch, minify, pulls apart, rewrites code. Any of your dependencies can simply crash, either due to a bug in that node version or simply an incompatibility.

Anyhoo, did it work? :slight_smile:

@IcyRizard Thanks for the detailed information.

We are already using node:10-alpine in docker. So I guess this didn’t resolve the issue.

Also I have verified there is no diff in the package.json

What about your lockfile? If you don’t have one that means any number of packages could have changed version. Your package.json only specifies direct dependencies (and usually not even specific versions at that, it’s often ranges) but each of those dependencies have other dependencies which can change versions every time you do an npm/yarn install unless you’re using a lockfile

1 Like

Pushing the yarn.lock file resolved the issue for me. It was in .gitignore file earlier.