Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR in PasswordStrengthBarModule is not an NgModule #6

Open
ScottSpittle opened this issue Mar 8, 2017 · 8 comments
Open

ERROR in PasswordStrengthBarModule is not an NgModule #6

ScottSpittle opened this issue Mar 8, 2017 · 8 comments

Comments

@ScottSpittle
Copy link

ScottSpittle commented Mar 8, 2017

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

@evansmwendwa
Copy link
Contributor

Experiencing same issue

@rnadler
Copy link
Owner

rnadler commented Mar 11, 2017

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

@evansmwendwa
Copy link
Contributor

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

@Bigless27
Copy link

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

@rnadler
Copy link
Owner

rnadler commented Mar 19, 2017

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

@Bigless27
Copy link

@rnadler Yes it does, Thanks!

@DanielYKPan
Copy link

DanielYKPan commented Mar 25, 2017

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?

@evansmwendwa
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants