flauc / angular2-notifications

A light and easy to use notifications library for Angular.
https://stackblitz.com/edit/angular2-notifications-example
MIT License
746 stars 164 forks source link

Cannot find module 'angular2-notifications'. since Angular 5.2.10 #307

Open FrancescoBorzi opened 6 years ago

FrancescoBorzi commented 6 years ago

Using version 0.9.7

Since last time I've updated my packages, I'm getting this compilation error:

ERROR in src/app/app.module.ts(22,43): error TS2307: Cannot find module 'angular2-notifications'.

Apparently, replacing:

import { SimpleNotificationsModule } from 'angular2-notifications';

with:

import { SimpleNotificationsModule } from 'angular2-notifications/dist';

is solving the issue, but then my unit tests fail with:

Error: StaticInjectorError(DynamicTestModule)[options]: 
  StaticInjectorError(Platform: core)[options]: 
    NullInjectorError: No provider for options!
flauc commented 6 years ago

Can you please try updating to v1.0.0. I think you should not get that issue then, at least with @angular/cli

frauenknecht commented 6 years ago

Same here.

Some of my tests fail with:

          StaticInjectorError(Platform: core)[options]:
            NullInjectorError: No provider for options!
        Error: StaticInjectorError(DynamicTestModule)[options]:

Angular: 5.2.9 angular2-notifications: starting at 0.9.8. No difference with 1.0.0

iGrubesic commented 6 years ago

@frauenknecht are you using import { SimpleNotificationsModule } from 'angular2-notifications'; or import { SimpleNotificationsModule } from 'angular2-notifications/dist';

The first one works fine for me with 1.0.0 in @angular/cli production build

frauenknecht commented 6 years ago

@iGrubesic The First Import statement. However, compiling or running the code is not the problem. My unit tests are broken.

iGrubesic commented 6 years ago

I bet it has something to do with providing 'options' as a string and not an InjectionToken

https://github.com/flauc/angular2-notifications/blob/master/src/index.ts

flauc commented 6 years ago

I'm unable to recreate this. What environment are you using?

ghost commented 6 years ago

Same here.

frauenknecht commented 6 years ago

@flauc Jasmine 2.9 with new Angular 5 HttpClient and test support libraries.

flauc commented 6 years ago

The most frustrating thing is, it's working fine with karma and @angular/cli on Angular 5. Can you please create a minimal recreation on plunker?

blackyale commented 6 years ago

Had the same issue, updating to 1.0.0 solved it for me.

fromage9747 commented 6 years ago

Same issue here. Solved by using 1.0.0

DominicBoettger commented 6 years ago

Problem with 1.0.1 here. Seems that the main file can't be found. Downgraded to 0.9.7 and works.

FrancescoBorzi commented 6 years ago

I've just tried using version 1.0.2 (and Angular 5.2.11) and I'm still getting this error in most of my unit tests:

NullInjectorError: No provider for options!

downgrading to version 0.9.7 solves the issue for me.

EDIT: this looks to happen only when I import NotificationsService in my testbed among the providers. If I load the module SimpleNotificationsModule instead than it seems to be working fine.