ng2-password-strength-bar icon indicating copy to clipboard operation
ng2-password-strength-bar copied to clipboard

ERROR in PasswordStrengthBarModule is not an NgModule

Open ScottSpittle opened this issue 7 years ago • 8 comments

Using Angular CLI, installed the package, and for some reason the first compilation with 'ng serve' throws "ERROR in PasswordStrengthBarModule is not an NgModule".

If I make a random change to a file to trigger a rebuild it works fine...

http://puu.sh/uzpXz/ff33ba2f90.png

Version 1.1.1

ScottSpittle avatar Mar 08 '17 09:03 ScottSpittle

Experiencing same issue

evansmwendwa avatar Mar 08 '17 15:03 evansmwendwa

If you're having this problem, the workaround is to add PasswordStrengthBarComponent to the declarations instead of importing PasswordStrengthBarModule.

rnadler avatar Mar 11 '17 22:03 rnadler

I managed to fix a similar issue in another package that I am working on by doing AOT compilation using the ngc compilers instead of the tsc one.

More details on this article https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#compile

evansmwendwa avatar Mar 11 '17 22:03 evansmwendwa

I'm experiencing the same issues even using the PasswordStrengthBarComponent. I'm using version 1.1

Bigless27 avatar Mar 17 '17 21:03 Bigless27

@ScottSpittle and @Bigless27, Please confirm that v1.1.2 resolves the import problem. Thanks!

rnadler avatar Mar 19 '17 02:03 rnadler

@rnadler Yes it does, Thanks!

Bigless27 avatar Mar 20 '17 14:03 Bigless27

I have the same issue with my package.

To fix the issue, is it just compile my package by doing AOT compilation using the ngc compilers instead of the tsc and include those compiled files in my package?

Can you please give me hints to fix this problem?

DanielYKPan avatar Mar 25 '17 03:03 DanielYKPan

The ng-compiler generates additional metadata.json files that tsc does not emit. Those are required in some typescript setups to identify your exported components

You need to install the compiler and platform-server

npm install @angular/compiler-cli @angular/platform-server --save

Then you can point it to the same tsconfig or a different one if you want different optimizations

sample ts config

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "declaration": true,
    "outDir": "lib",
    "rootDir": "src"
  },
  "include": [
    "src/**/*"
  ]
}

You can integrate in your npm scripts

"build": "rm -rf lib && \"node_modules/.bin/ngc\" -p tsconfig-aot.json"

Then execute in the cli once you are ready to build

npm run build

You can find more details in the documentation https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#compile

evansmwendwa avatar Mar 25 '17 13:03 evansmwendwa