0

Getting this error in firebug after angular2 app has been deployed : "TypeError: this._nativeError is undefined" in app.js.

*app.js is the javascript that is created from npm run build.prod.aot (and also npm run build.prod).

App runs fine locally, it only seems to give me problems after I've deployed to a standalone web server. I assume I have a minor typo somewhere, but the error looks pretty generic and I can't find anything conclusive as to what might be the cause.

Has anyone seen this issue before? Or have any idea how to narrow down my search in finding it?

Edit: Using this seed project: https://github.com/mgechev/angular-seed but comments/answers are suggesting that others have had issue despite using other starters

Joff
  • 95
  • 1
  • 8
  • getting same issue . – Sameer K Jan 13 '17 at 09:20
  • Are you using ng2-bootstrap ?? I am getting this issue due to ng2-bootstrap – Sameer K Jan 13 '17 at 10:30
  • @SameerK I haven't added any third party stuff yet and I don't think the seed project uses this (could be wrong), have you found a fix to this? Still might be relevant – Joff Jan 13 '17 at 14:15
  • I found that tooltip was one of the module from ng2-bootstrap which was creating this issue, so while importing it i added like `TooltipModule.forRoot(),`. Still have issues with other modules of ng2-bootstrap – Sameer K Jan 13 '17 at 15:05
  • @SameerK Just to double check, your app builds fine locally and in dev right? You only see this when deploying to dist/prod and moving the files to a web server? I think you might be on to something with the imports of certain modules – Joff Jan 13 '17 at 15:27
  • I have just created a project with angular-cli and I see it as well. The pristine generated project works, but as soon as I try to modify the template of the app component, I get this error. I think that I am introducing an error in the template but that the error reporting from Angular is broken. – simark Jan 13 '17 at 21:09

4 Answers4

3

Around line 1604 in the compiler.umd.js I added a console.log to show me the message.

It is part of the set function of the Object.defineProperty(BaseError.prototype, "message" definition.

The setter is assigning the message to the _nativeError.message, but _nativeError is undefined and thus, THAT was blowing up, hiding the REAL error message.

So, I just put a console.log to spit out the message that was being passed in, and it showed me the actual error I had (a template error).

Therefore, this appears to be a bug in their code.

Hope that helps.

  • Might be worth noting that there are other js files (common.umd.min.js, and core.umd.min.js) that you might need to add the console.log to. Mine was not compiler.umd.js and it revealed a DI Error. Not 100% which file did the trick for me, I changed 5-6 of the ones I saw this._nativeError.message=message – Joff Jan 14 '17 at 02:16
  • I changed the set in compiler.umd.js (Angular v2.4.1) at line 1607 My set looks like this: `set: function (message) { console.log(message); this._nativeError.message = message; },` – Nick Feb 01 '17 at 15:41
2

Thanks!!! For me it simply worked without uninstalling but just simply installing: npm install zone.js@0.72 - Than node_modules/zone.js/package.json contained _id 0.7.2 rather than 0.7.5 and the error messages became as beautifull as before

1

I had the same error: "TypeError: this._nativeError is undefined", but I do not use angular-seed.

My stack trace:

.set
    assignAll
    ZoneAwareError
    BaseError
    SyntaxError
    CompileMetadataResolver.prototype._getDependenciesMetadata
    CompileMetadataResolver.prototype._getTypeMetadata
...

The error was removed after setting: "emitDecoratorMetadata": true in tsconfig.json.

1

I had the same problem and same message. It is a known issue to zone.js version 0.7.5 that the actual error messages are not displayed properly - see also here: Github Issues on zone.js 0.7.5 First I thought, I had version 0.7.2 because the package manager showed me that I had, but I tried and deinstalled with npm, afterwards installed 0.7.2 and now I have a beautiful error message pointing me directly on the nose of the error :) Hope that helps you, too.

seawave_23
  • 1,169
  • 2
  • 12
  • 23
  • I still get the same vague error message but +1 for the recommendation to update everything - was a little out of date and it is always a good place to start and might help someone else – Joff Jan 14 '17 at 18:36
  • it was not a recommendation to update, more to down-date ;) – seawave_23 Jan 21 '17 at 08:37