question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem using with angular-cli webpack 1.0.0-beta.14

See original GitHub issue

Hi, I’m trying to use this module with no luck. My project is using the latest from angular-cli so no system.js anymore. Therefore, the setup pard of the readme.md is irrelevant for me.

In my app.module.ts I import: import { SimpleNotificationsModule, NotificationsService } from 'angular2-notifications';. SimpleNotificationsModule goes to the import array and NotificationsService is going to the providers array (which wasn’t in the readme.md file but seems needed, wouldn’t it?).

In the app.component.html I simply added <simple-notifications [options]="options"></simple-notifications> to the 1st row. And that’s it, no more calls at this stage.

Can you help me configure this in angular-cli.json, if needed? The errors I get:

error_handler.js:45EXCEPTION: Error in ./AppComponent class AppComponent - inline template:0:22 caused by: Cannot convert undefined or null to objectErrorHandler.handleError @ error_handler.js:45(anonymous function) @ application_ref.js:209ZoneDelegate.invoke @ zone.js:192onInvoke @ ng_zone_impl.js:43ZoneDelegate.invoke @ zone.js:191Zone.run @ zone.js:85(anonymous function) @ zone.js:451ZoneDelegate.invokeTask @ zone.js:225onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:224Zone.runTask @ zone.js:125drainMicroTaskQueue @ zone.js:357 error_handler.js:47ORIGINAL EXCEPTION: Cannot convert undefined or null to objectErrorHandler.handleError @ error_handler.js:47(anonymous function) @ application_ref.js:209ZoneDelegate.invoke @ zone.js:192onInvoke @ ng_zone_impl.js:43ZoneDelegate.invoke @ zone.js:191Zone.run @ zone.js:85(anonymous function) @ zone.js:451ZoneDelegate.invokeTask @ zone.js:225onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:224Zone.runTask @ zone.js:125drainMicroTaskQueue @ zone.js:357 error_handler.js:50ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:50(anonymous function) @ application_ref.js:209ZoneDelegate.invoke @ zone.js:192onInvoke @ ng_zone_impl.js:43ZoneDelegate.invoke @ zone.js:191Zone.run @ zone.js:85(anonymous function) @ zone.js:451ZoneDelegate.invokeTask @ zone.js:225onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:224Zone.runTask @ zone.js:125drainMicroTaskQueue @ zone.js:357 error_handler.js:51TypeError: Cannot convert undefined or null to object at SimpleNotificationsComponent.attachChanges (simple-notifications.component.js:110) at SimpleNotificationsComponent.set [as options] (simple-notifications.component.js:36) at DebugAppView._View_AppComponent0.detectChangesInternal (AppComponent.ngfactory.js:59) at DebugAppView.AppView.detectChanges (view.js:272) at DebugAppView.detectChanges (view.js:377) at DebugAppView.AppView.detectViewChildrenChanges (view.js:298) at DebugAppView.AppView.detectChangesInternal (view.js:283) at DebugAppView.AppView.detectChanges (view.js:272) at DebugAppView.detectChanges (view.js:377) at ViewRef_.detectChanges (view_ref.js:130)ErrorHandler.handleError @ error_handler.js:51(anonymous function) @ application_ref.js:209ZoneDelegate.invoke @ zone.js:192onInvoke @ ng_zone_impl.js:43ZoneDelegate.invoke @ zone.js:191Zone.run @ zone.js:85(anonymous function) @ zone.js:451ZoneDelegate.invokeTask @ zone.js:225onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:224Zone.runTask @ zone.js:125drainMicroTaskQueue @ zone.js:357 error_handler.js:54ERROR CONTEXT:ErrorHandler.handleError @ error_handler.js:54(anonymous function) @ application_ref.js:209ZoneDelegate.invoke @ zone.js:192onInvoke @ ng_zone_impl.js:43ZoneDelegate.invoke @ zone.js:191Zone.run @ zone.js:85(anonymous function) @ zone.js:451ZoneDelegate.invokeTask @ zone.js:225onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:224Zone.runTask @ zone.js:125drainMicroTaskQueue @ zone.js:357 error_handler.js:55DebugContext {_view: _View_AppComponent0, _nodeIndex: 0, _tplRow: 0, _tplCol: 22}ErrorHandler.handleError @ error_handler.js:55(anonymous function) @ application_ref.js:209ZoneDelegate.invoke @ zone.js:192onInvoke @ ng_zone_impl.js:43ZoneDelegate.invoke @ zone.js:191Zone.run @ zone.js:85(anonymous function) @ zone.js:451ZoneDelegate.invokeTask @ zone.js:225onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:224Zone.runTask @ zone.js:125drainMicroTaskQueue @ zone.js:357 zone.js:344Unhandled Promise rejection: Error in ./AppComponent class AppComponent - inline template:0:22 caused by: Cannot convert undefined or null to object ; Zone: <root> ; Task: Promise.then ; Value: ViewWrappedError {_nativeError: Error: Error in ./AppComponent class AppComponent - inline template:0:22 caused by: Cannot convert u…, originalError: TypeError: Cannot convert undefined or null to object at SimpleNotificationsComponent.attachChan…, context: DebugContext} TypeError: Cannot convert undefined or null to object at SimpleNotificationsComponent.attachChanges (http://localhost:4200/main.bundle.js:49219:16) at SimpleNotificationsComponent.set [as options] (http://localhost:4200/main.bundle.js:49145:18) at DebugAppView._View_AppComponent0.detectChangesInternal (AppComponent.ngfactory.js:59:52) at DebugAppView.AppView.detectChanges (http://localhost:4200/main.bundle.js:62539:14) at DebugAppView.detectChanges (http://localhost:4200/main.bundle.js:62644:44) at DebugAppView.AppView.detectViewChildrenChanges (http://localhost:4200/main.bundle.js:62565:19) at DebugAppView.AppView.detectChangesInternal (http://localhost:4200/main.bundle.js:62550:14) at DebugAppView.AppView.detectChanges (http://localhost:4200/main.bundle.js:62539:14) at DebugAppView.detectChanges (http://localhost:4200/main.bundle.js:62644:44) at ViewRef_.detectChanges (http://localhost:4200/main.bundle.js:44554:20)consoleError @ zone.js:344_loop_1 @ zone.js:371drainMicroTaskQueue @ zone.js:375 zone.js:346Error: Uncaught (in promise): Error: Error in ./AppComponent class AppComponent - inline template:0:22 caused by: Cannot convert undefined or null to object(…)consoleError @ zone.js:346_loop_1 @ zone.js:371drainMicroTaskQueue @ zone.js:375

I also tried to add the file to the script array in the json file: ../node_modules/angular2-notifications/components.js but that of course wouldn’t work due to:

VM1017:1Uncaught ReferenceError: exports is not defined(anonymous function) @ VM1017:1module.exports @ addScript.js:9242 @ components.js?adcb:1__webpack_require__ @ bootstrap 0def24d…:52727 @ addScript.js:10__webpack_require__ @ bootstrap 0def24d…:52webpackJsonpCallback @ bootstrap 0def24d…:23(anonymous function) @ scripts.bundle.js:1 metadata_resolver.js:235Uncaught Error: Unexpected value 'undefined' imported by the module 'AppModule'

I have tried adding other files from lib or src and it didn’t work. Do you have a solution for that?

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mrgooscommented, Sep 19, 2016

@flauc - please ignore the lase comment. It’s because I had (onCreate)="created($event)" with no implementation. So everything is working great! Thanks for this module.

1reaction
mrgooscommented, Sep 19, 2016

Hey @flauc - So I have some progress here. I had that error since I haven’t declared options object in my .component.ts. After declaring the options it has no errors anymore. And I have made some research re 3rd parties libs in angular-cli. So it seems that since you’re module exports modules, I can do as it says in their readme which is to just import modules and I have no errors about it.

The problem is, when I do try to test it I get another error: error_handler.js:45 EXCEPTION: Error in ./AppComponent class AppComponent - inline template:0:42 caused by: self.context.created is not a functionErrorHandler.handleError @ error_handler.js:45next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:196Zone.runGuarded @ zone.js:102NgZoneImpl.runInnerGuarded @ ng_zone_impl.js:72NgZone.runGuarded @ ng_zone.js:236outsideHandler @ dom_events.js:26ZoneDelegate.invokeTask @ zone.js:225Zone.runTask @ zone.js:125ZoneTask.invoke @ zone.js:293 error_handler.js:47 ORIGINAL EXCEPTION: self.context.created is not a function......

I just added a button to test it: <button (click)="test()">Test Error</button> And in the implementation I have: test() { this._notificationsService.success('example title', 'example content'); }

I added this to the constructor: constructor(private _notificationsService: NotificationsService) { }; BTW - shouldn’t you add to your readme that you need to put NotificationsService as a global provider?

Can you estimate what’s wrong now? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular-cli 1.0.0-beta.14 has install errors on El Capitan #2204
angular-cli : 1.0.0-beta.14 node: 6.6.0 os: darwin x64; Repro steps. Was this an app that wasn't created using the CLI? What change did...
Read more >
Getting very weird error while using angular/cli version 1.0.0 ...
It's very hard to debug such a problem. There are many dependencies with libraries and also node version (which is what?). The best...
Read more >
@angular/cli - npm
@angular/cli. TypeScript icon, indicating that this package has built-in type declarations. 1.0.0-beta.28.3 • Public • Published 6 years ago.
Read more >
angular/angular-cli - Gitter
When I start a project created using the latest angular-cli version (1.0.0-beta.14), I get the error "Cannot find name 'require'".
Read more >
Changelog of the pack - Angular Pro Pack - Ninja Squad
'Login' now uses a template-driven form because they are simpler. Bump to angular-cli 1.0.0-beta.11-webpack.2; To update angular-cli, check ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found