user5819768
user5819768

Reputation:

Easily debug Ionic 2 apps

I'm new to ionic and I have an error coming and going during the build

build dev failed: Cannot read property 'indexOf' of undefined 

I say come and go because I have no clue where it comes from, and it seems to appear sometime and sometime not for the same code base.

It is also an understatement to say that this error message does not help, so I'm wondering. Where should I look at to try to understand where it wants to see this index of an undefined item ?

Thanks!

Upvotes: 1

Views: 73

Answers (1)

misha130
misha130

Reputation: 5726

I do this personally and this isn't the best answer but you could change the node modules logger.js to display the full stack.

I guess ionic team just didn't expect you would encounter these errors or more likely idealistically you shouldn't encounter them or fix them. I think this was their idea.

You may go to .\node_modules\@ionic\app-scripts\dist\logger\logger.js

On this here line:

 var failedMsg = this.scope + " failed";
                if (err.message) {
                    failedMsg += ": " + err.message;
                }

Change it to this:

  var failedMsg = this.scope + " failed. Stack: " + err.stack;
                if (err.message) {
                    failedMsg += ": " + err.message;
                }

Hope someone could suggest a cleaner solution.

Or run like this npm run ionic:build --debug

Upvotes: 0

Related Questions