inorganik / ngx-countUp

Animates a numerical value by counting to it - for Angular

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR in ./node_modules/countup.js-angular2/countUp.module.ts

Farre82 opened this issue · comments

Module build failed: Error: C:\XXX\node_modules\countup.js-angular2\countUp.directive.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include'
property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).

How are you including the countUp.js-angular2 module?

Hi,
I' m using angular 5 and is including countup.js in my sharedModule like this.

`import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { CountUpModule } from "countup.js-angular2";

@NgModule({
imports: [
CommonModule,
FormsModule,
CountUpModule
],
declarations: [
],
exports: [
CommonModule,
FormsModule,
CountUpModule,
]
})
export class SharedModule { }
`

Hi again,
I think it have to do with Angular 5 and AOT.
See this link AOT

Gonna need some more info please. What angular version, cli version, and countup.js-angular2 version are you using? I successfully included it in a project using these latest (at time of writing) versions:

Angular: 5.2.0
Angular CLI: 1.6.5
count Up Angular2: 1.1.1

At the very least, make sure you have the most recent countup.js-angular2 version, 1.1.1.

The problem appears when we try to compile for production (in my case it's in Ionic, but i think it's the same problem of the others). The Angular compiler (version 5.2.9 in my case) is looking for the compiled js files, but in the npm module there are only the typescript files.

I am able to successfully compile my test project with ng build --prod.

In the dist folder, everything is compiled down to js.

Having the same issue now that I upgraded to v6.

ng build --prod

ERROR in ./node_modules/countup.js-angular2/countUp.directive.ts
Module build failed: Error: countUp.directive.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
    at AngularCompilerPlugin.getCompiledFile 

Angular 6.0.0
Angular CLI: 6.0.0
CountUp: 1.1.1

It was building fine in v5.*, but it looks like with the upgrade, that's no longer the case.

EDIT:
In the meantime, I was able to find a workaround by adding the following to the end of tsconfig.json, just as the error suggests:

"include": [
    "./src"
  ],
  "files": [
    "node_modules/countup.js-angular2/countUp.module.ts",
    "node_modules/countup.js-angular2/countUp.directive.ts"
  ]

With that in place, my projects builds fine with ng build --prod

Any word on this? I am experiencing this as well. As @iplaksiy noted, the error message says the following:

Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).

For now, use @iplaksiy's solution. I tried rerunning a newer version of ng-packagr, and it results in an AOT error:

ERROR in : Unexpected value 'CountUpModule in /.../node_modules/countup.js-angular2/countUp.module.d.ts' imported by the module 'AppModule in /.../src/app/app.module.ts'. Please add a @NgModule annotation.

Angular still hasn't figured out a good way to pass directives around via npm. Of course, you can always just copy the count-up directive in this repo and declare it in app.module.ts. It's really that simple! But due to all the complicated webpack bundling, transpiling, etc, we have to jump through so many hoops if we want to just npm install it. * sigh *

Fixed in v6.0.0