angular2-notifications icon indicating copy to clipboard operation
angular2-notifications copied to clipboard

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

Open FrancescoBorzi opened this issue 6 years ago • 14 comments

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!

FrancescoBorzi avatar Apr 16 '18 09:04 FrancescoBorzi

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

flauc avatar Apr 16 '18 10:04 flauc

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

frauenknecht avatar Apr 16 '18 10:04 frauenknecht

@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

iGrubesic avatar Apr 16 '18 19:04 iGrubesic

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

frauenknecht avatar Apr 16 '18 20:04 frauenknecht

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

iGrubesic avatar Apr 16 '18 20:04 iGrubesic

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

flauc avatar Apr 16 '18 20:04 flauc

Same here.

ghost avatar Apr 16 '18 20:04 ghost

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

frauenknecht avatar Apr 16 '18 21:04 frauenknecht

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?

flauc avatar Apr 16 '18 21:04 flauc

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

blackyale avatar Apr 17 '18 09:04 blackyale

Same issue here. Solved by using 1.0.0

fromage9747 avatar Apr 27 '18 04:04 fromage9747

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

DominicBoettger avatar Apr 30 '18 17:04 DominicBoettger

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.

FrancescoBorzi avatar Jun 07 '18 12:06 FrancescoBorzi