You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular 5: NPM Link - model/index.ts is not part of the compilation. #8284
When using Angular 4.46 and Angular CLI 1.5.rc2 and we were able to make reference to the interfaces defined in the model folder using npm link and using the following example import { entity } @app/model
We use ng serve to start the app.
After upgrading Angular to V5 and Angular CLI to 1.5.0 we now get the following error -
The log given by the failure.
Module build failed: Error: /Users/thaoula/Projects/platform/model/index.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The occurs for JIT and AOT builds.
Running TSC does not result in in errors.
Desired functionality.
Would like be able to build the app using Angular 5
Thanks,
Tarek
Reacted by Jason Stone, Christian Schrödel, Theo Harper, Sunil Mekala, Paolo Moretti, Michalis Tzikas, Enterprise Software Architecture, Onin, Ben Elliott, Alex Beugnet and 63 more
@MakesNine so if you try having a file with just interfaces it's still fine in a new project? Hm... I've heard of problems with casing. Are your imports perhaps using the wrong casing? Does it still happen if you add a non-interface export to that file? That seems to be a lazy route, perhaps it's related. Can you try making that route not lazy?
@KevinFernandes this definitely shouldn't happen to all library packages, unless somehow you're just using packages that weren't packaged well. Can you give me examples of a couple of these packages? I can have a look.
@filipesilva yest, I can build a new project and import a file with only interfaces from a lazy loaded module. I will double check the casing and try the original app with a non lazy route for the module where the error originates.
@filipesilva I have added an import and exported a function from the file refusing to be part of the compilation and it didn't help.
I have changed all the routes, in app-routing.module.ts, that have components importing type definitions from that file so that they wouldn't be lazy loaded and the app compiled, but didn't work. I had forgotten to import the modules, in app.module.ts', that contained the components now used in the non lazy loaded routes. Once I add the required imports in app.module.ts, I get the same problem that I get with lazy loaded routes. I have also checked casing and all seems ok on that front.
Thanks @filipesilva - that explains my issue.
I tried explicitly including my internal libraries using include, but that's giving me other grief (picking up on test suites, despite using exclude). So I'll do it properly and have them expose compiled code.
I knew it was something I should do, but with them only being used internally by the company, I let it slide.
Thanks again to you and all the contributors for your hard work on Angular CLI - it's an excellent tool and very much appreciated.
I was having the same issue after updating. Like some other people, the ts files were all part of the standard CLI structure tree. Turned out it was a case sensitivity issue for me. I had accidentally written something like...
import { Comment } from './Comment' while in other components import { Comment } from './comment'. Running a normal build would throw me a helpful warning before erroring out, but building for prod only showed me the "Please make sure it is in your tsconfig via the 'files' or 'include' property" error. Fixed the casing issue and prod builds for me fine.
Reacted by dsoltesz, Nanditha, av09, Sri chakra Koppula, Dillon Fletcher, Alex, Jonathan Rial, ChrisAllisonMalta, Antony Booth, Tim Schimandle and 3 more
I finally got my app to compile. It turned out that it was a casing issue indeed.
The error I was getting was:
ERROR in ./src/app/core/StateManagement/models/genericCourse.models.ts
And the solution is to change the related import to:
./src/app/core/stateManagement/models/genericCourse.models.ts
Curiously, I have other files in that folder that were also imported with StateMangement in the path and the compiler didn't complain.
@MakesNine that is weird indeed, and I'm not really sure why that happens... I expected all bad paths to throw an error somehow. Will keep an eye out for more such casing reports.
@filipesilva I see hundreds of errors so its hard to sort through them. From what I can see at the moment it's all of "my" library packages, packages that we build and publish to a local repository. We package all of the .ts files as well as a webpacked bundle file.
When we were building with SystemJS it made sense that we had to explicitly specify all of the bundles to include from node_modules, but with the CLI it seemed to just work without any extra specifications. It made our lives a thousand times easier. But now it seems what we thought was a feature was actually a bug in CLI and possibly something that we are doing wrong (and have been for more than a year now).
So what exactly is the problem? Is it that the CLI was compiling the .ts files that we had in our library packages and so did not need the bundles? If that is the case then how do we now tell the CLI to use the bundle? Is it something to do differently when packaging the library bundles or is it some angular-cli.json configuration we have to change.
Sorry, up until now we had though we had finally figured out this JavaScript eco system, but now it seems we still have some things to learn.
@KevinFernandes ok so that it happens on your local libs makes sense considering the other reports in this issue. Yes, before it seems like the CLI was compiling the TS in your local libraries, which was just a ticking time bomb really.
The way to address this in your codebase really depends on how you build your libs... Do you use an existing library to do it? I think a lot of users use https://github.com/dherges/ng-packagr and seem to be happy with it. I haven't myself though.
Reacted by Danny Blue, Samuel Marks, Metod Ribič and Bjorn S
I have a standard, cli generated, folder structure ( Windows platform )
I simply share some modules between different applications at the source level.
Under src there are the following folders:
app
packages ( simlink )
Under packages:
combo-components
....
Each folder is a module ( proper module.ts ) and has an index.ts for the exports.
An import statement looks like this: import { DataSourceResult, NotificationService } from '@combo-components/core';
It worked fine till angular 4.x and cli 1.4.x
After upgrading to 5.0 & cli 1.5.0, ng build fails with the following error:
ERROR in ../catol/combo-components/src/index.ts
Module build failed: Error: C:\Users...\workspace\catol\combo-components\src\index.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/app.module.ts 13:0-63
@ ./src/main.ts
@ multi ./src/main.ts
Casing checked, also added the include property suggested by @filipesilva
ERROR in ./src/main.ts
Module build failed: Error: C:\Users...\workspace\playground\src\main.ts is not part of the compilation output. Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
at plugin.done.then (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\loader.js:467:39)
at process._tickCallback (internal/process/next_tick.js:109:7)
@ multi ./src/main.ts
ERROR in ./src/polyfills.ts
...
Adding main&polyfill to the include path doesn't help either.
Reacted by Julio Carneiro, Yulin Dong, oroncohen, Jesu Arockia, Tiger, jessica-liyan and Nico Van Belle
Reacted by Marlon Reid, Simon Nodel, Svetozar Belić, Kerwin Bryant, yusuke-oba1, HollisTech, Tiger, wikiwaleed2, BrightShadow, zealitude and 3 more
Reacted by Julio Carneiro, Kerwin Bryant, HollisTech, wikiwaleed2, BrightShadow and Sebastian Molano
Reacted by Obaid ur Rehman, Alberto Aldegheri, Simon Nodel, Kerwin Bryant, HollisTech, Melanie Kanavakatini, Tiger, wikiwaleed2, BrightShadow, Peter Kiss and 1 more
I'm using a 3rd party library from Google called api-ai-javascript which is installed in the node_modules folder, using ng serve --preserve-symlinks does not work and neither does updating my angular-cli.json file, I have to explicitly update my tsconfig file with include in order to overcome the following error
Module build failed: Error: C:\Users\Development\Documents\Projects\proj\node_modules\api-ai-javascript\index.ts is not part of the compilation output. Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile (C:\Users\Development\Documents\Projects\proj\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
at plugin.done.then (C:\Users\Development\Documents\Projects\proj\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./src/app/services/bot/bot.service.ts 12:0-48
@ ./src/app/components/common/app-common.module.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
Only after updating to Angular 5.0.0 and Angular-cli 1.5.0 did the issue start occurring.
Reacted by Maicon Wagner, km, oroncohen, Oleg Musienko, Lorenzo Zaccagnini, Ashish Singh Rawat, Charles Thomas, Alex Tolkachev, Diana Quintanilla Perez, Sandeep Chikhale and 3 more
I'm also seeing the issue after upgrading to Angular 5 and cli 1.5.0 with a third-party logger module that had no issues previously.
Tried suggested methods posted here still the same error.
ERROR in ./node_modules/angular2-logger/app/core/level.ts Module build failed: Error: node_modules/angular2-logger/app/core/level.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
Reacted by Mehdi, Moo, sausagemaker and Diana Quintanilla Perez
I am have the same error, although mine came about after I imported the 'Input' class from '@angular/core'.
import {Component, OnInit, ViewEncapsulation, Input} from '@angular/core';
After I used the @Input() on the variable hero: Hero it breaks. If I don't type hero like @Input() hero it is fine, but as soon as I add : Hero; it breaks.
@scottieslg pointed me in the right direction. (Typo in path casing). Additionally I had several backticks (`) in my compoments that were compiling before. single quotes (') resolved the issue.
I encountered the problem with a project having a Symfony like architecture.
Meaning there is :
./tsconfig.json
./src/tsconfig.app.json
./src/SomeFolder/app/*.ts...
There are dependencies between each bundles.
One of the dependencies was thrown in "...is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property"
I solved the problem by including every ts files as suggested by @filipesilvabut in a different order.
=> Bundle B needed by Bundle A & C
so tsconfig.app.json like : { "include": [ "pathToBundleB/**/*.ts", "pathToBundleA/**/*.ts", "pathToBundleC/**/*.ts", ] }
instead of : { "include": [ "pathToBundleA/**/*.ts", "pathToBundleB/**/*.ts", "pathToBundleC/**/*.ts", ] }
That's kinda weird. Looks like @ngtools/webpack/src/angular_compiler_plugin.js:624:23), the function this._compilerHost.fileExists is looking for bundles loaded before, and not after..
I'm getting this error for files that are referenced in our app.module.ts. Its almost like this file is treated differently in some way because its the module referenced in the AngularCompilerPlugin options??? I've tried manually adding the module to the tsconfig files section but that hasn't resolved it.
We are having the same issue. We have a private repo where we have published a library that we use. We have this lib as a dependency in our client, when compiling in Angular 5 we get the following error but ONLY in JIT mode, if we use a ng serve --aot or ng build --aot or --prod it works fine. Not sure what is the issue here. We are using Angular 5.0.1 with CLI 1.5.0
We tried using includes in tsconfig, while that solves this issue it generates another different error that my json module declarations are not found which is specified in typings.d.ts (with a declare module "*.json").
ERROR in ./node_modules/@myscope/services-lib/index.ts
Module build failed: Error:
[path]\node_modules\@myscope\services-lib\index.ts is not part of the compilation output.
Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile ([path]\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
Reacted by Yulin Dong, Steffen Arntz, Brandon and R2Djew
I've managed to resolve the issue I was having by, as per @filipesilva's advice, compiling the TS code from my library and configuring it so my downstream projects could consume it.
I did have a lot of trouble with this though, so I want to share some details in the hope they'll help others with the same frustrations.
Most of the documentation and discussion available frames these repos we're installing via npm as "libraries" in the open source sense of the term: The code is on github, the artifacts are published to npm, and they must be built for general consumption (ie. accounting for different projects with different ES targets).
My situation (which is not unique, from the sound of things) is different in that my "library" is for internal company use only.
To help separate this use case from the "open source library" scenario, I'm going to call what I've got a "shared codebase".
Your starting point should be @filipesilva's angular-quickstart-lib repo.
If, like me, you've got a "shared codebase" then you don't need everything from here. The key things you need are:
To inline resources before you compile them (ie. templateUrl becomes template)
To compile the TS code using ngc, with appropriate tsconfig.json settings
To add module and typings properties to your package.json, pointing at the index.js and index.d.ts of your compiled code.
What you don't need is bundling (Just use the raw *.js files), and you probably only need a single compile target (ES5 or ES2015).
So you can strip down a lot of the build.js file (removing the need for a fair few extra npm dependencies) and ignore references to flatModule in the tsconfig.lib.json.
I hope that helps.
Reacted by Sandy, Danny Blue, Filipe Silva, André Gomes, Tyler Danielson and Sonia C.
Myself and my team, we have put all energy believing and trusting Angular,
that's this time things will be different not like from angularJs to angular 2.
And we could jump a long time from angularJs to ReactJs or Aurelia or maybe VueJs,
but the love and trust we had it keeps as loving Angular and believing that we won't have same stress like we had from angularJs to angular 2.
Now we already with big projects out there, using third-party open source libraries, which till angular 4.3, everything was fine.
But now in angular 5 with the CLI 1.5, we were expecting the upgrade to be smooth and not having this kind of issue.
So now we're stuck and hoping that the creators of the libraries they update the package.
And the questions come again, should we keep believing that angular will have the success like angularJs had on the past, or now is time to move on trying something different because this is a nightmare, and each version got different stories, and we must signup new courses to learn over.
I'm sorry for my comments, but this how it feels like.
Reacted by Franziskus Karsunke, Koray Güclü, Volodymyr Dovbenko, Kevin, Alexander Bich, Terry Moore, Kristof Verslegers, David Klingenberg, Christoph Bühler, Ashish Singh Rawat and 9 more
@jjoao07 Sorry you are having trouble. The issue isn't an angular issue it is a typescript issue. To solve it for linked libraries that have typescript shipped in them you can add that to your tsconfig "includes" property. So if you have a folder in your node modules called "my-lib" you can add. The typescript compiler by default does not see the typescript code in node_modules by default (and it shouldn't). I hope this helps.
@deebloo if the Typescript compiler shouldn't be looking at ts code in the node modules then perhaps adding an includes is not the best solution for this? Should we be packaging our libraries differently?
Reacted by Danny Blue, Franziskus Karsunke, Richard William and Nico Van Belle
@sbkpilot1 overall yes. if you are publishing a module you should only be distributing javascript and the generated type definitions. The solution I mentioned is only a workaround
hello guys,
I had the same issue in my project (Angular 5.0.0).
I solved it by deleting the file which causes the problem.
After i created it again and pasting the same code step by step in order to make sure what part of the code cause the problem.
Now everything work.
Hope my solution will help you.
while compiling the solution via ng serve -o after angular 5 update this issue occurs.
i have used npm link to link all my modules.
ERROR in ./platform/userModule/app/app.module.ts
Module build failed: Error: E:\temp\trunk\platform\userModule\app\app.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (E:\temp\trunk\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (E:\temp\trunk\node_modules@ngtools\webpack\src\loader.js:467:39)
at
@ ./src/$$_lazy_route_resource lazy
@ ./node_modules/@angular/core/esm5/core.js
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./src/app/hero.ts
Module build failed: Error: F:\lenleeWorkProject\angular\angular-tour-of-heroes\src\app\hero.ts is not part o
f the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (F:\lenleeWorkProject\angular\angular-tour-of-heroes\node_module
s@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (F:\lenleeWorkProject\angular\angular-tour-of-heroes\node_modules@ngtools\webpack\sr
c\loader.js:467:39)
at
@ ./src/app/hero-detail/hero-detail.component.ts 11:0-31
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
============================
i am check all the hero.ts reference, The discovery problem appears on the file path
is Uppercase the Hero Instead of hero 。
so why path error not prompting?
Instead, it returns to normal after manually triggering the save
Hello, I came across the same issue using angular 5.0.1 and CLI 1.5 :
Module build failed: Error: xxx\ng4-blog-frontend\src\app\models\post.ts is not part of the compilation. Please make sure it is in your tsconfig via the
'files' or 'include' property.
At first I had a case issue that I solved and it worked fine for a while but the error came back somehow later.
I tried what @sandangel suggested by using the flag --preserve-symlinks but it did not worked.
Finally, I found another issue (#20091) where @stephanecot suggested the use of --aot and it works fine, although I have no idea why...
As the flag suggests, it use the Ahead of time compilation which can be unwanted.
What I did with my library is I moved it to the src folder and included it from there. Not a clean solution, but it'll work until the Angular guys figure this one out.
I have same symptoms like @nueko has. When one of my dependencies is linked via symlink and I invoke ng build --prod --build-optimizer - then it fails. --preserve-symlinks helps to fix this particular case: ng build --prod --build-optimizer --preserve-symlinks
Module build failed: Error: C:\...\src\app\hero.ts is not part of the compilation.
Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (C:\...\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:620:23)
at plugin.done.then (C:\...\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>
@ ./src/app/hero-details/hero-details.component.ts 11:0-31
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
We're using the "shared codebase" approach @rolaveric is using and I managed to get it to compile and run fine by adding the following include to the tsconfig.json:
That all works great, however if I try and run ng test I end up with the same build errors that I got before adding our shared codebase to the includes (Module build failed: "{sharedcodebasename}/file.ts" is not part of the compilation output.
Now @filipesilva I appreciate you saying this isn't the "proper way to do an NPM package", but for my case (and what looks like a few others in this thread), we have internal company "packages" that we don't want pushing to NPM (we push them to our private Nexus repo) and publishing typescript files as a package is exactly what we need. Is there any way that this can be resolved? I understand the rationale behind the change in compilation behaviour, but it seems to be causing many unintended headaches.
Reacted by lichunbin814, Harun Hasdal, Brandon, Bjorn S and Cameron Plimsoll
@mattytommo, instead of editing tsconfig.json like that, you can add the include(s) into tsconfig.app.json + tsconfig.spec.json (prefixed with ../ of course). I know that's slightly uglier. :)
@rkrisztian I must have tried it in those files 100 times, but I don't think I actually prefixed with ../ because adding that to the spec.json file works!!
So, essentially, as long as you put the include within the spec.json (for the tests) and the tsconfig.json (or .app.json), the build and tests work. Thanks again rkrisztian.
I don't think is a problem of angular-cli. I compile my projects directly with webpack and my own config files and I have the same problem if a use AOT option with Angular 5.x.x but it's perfect in Angular 4.x.x. But if I don't use AOT option the compilation is fine even in Angular 5.x.x.
It's very strange but the problem is that some DTOs classes are not included in the compilation process. I have 15 DTO classes in src\app\common\dto directory and 16 POJO classes in src\app\common\data directory and some of them are not included in the compilation process. I reviewed the Javascript files generated by the AOT compiler and they don't appear in any place. But if I don't use AOT or I use Angular 4.x.x all the classes are included in the compilation process.
Maybe the bug is in the Ahead-of-Time compiler in Angular 5.x.x or in the Webpack Plugin: @ngtools\webpack
ERROR in ./src/app/common/dto/SolicitanteDTO.ts
Module build failed: Error: G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\src\app\common\dto\SolicitanteDTO.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:643:23)
at plugin.done.then (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/citas/component/cita-form-new.component.ts 19:23-65
@ ./src/app/citas/cita.module.ngfactory.js
@ ./$$_lazy_route_resource async
@ ./~/@angular/core/esm5/core.js
@ ./src/main-aot.ts
ERROR in ./src/app/common/dto/SolicitanteCampoDTO.ts
Module build failed: Error: G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\src\app\common\dto\SolicitanteCampoDTO.ts is not part of the compilation. Please make sure it is
in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:643:23)
at plugin.done.then (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/citas/component/cita-form-new.component.ts 18:28-75
@ ./src/app/citas/cita.module.ngfactory.js
@ ./$$_lazy_route_resource async
@ ./~/@angular/core/esm5/core.js
@ ./src/main-aot.ts
ERROR in ./src/app/common/data/reserva.ts
Module build failed: Error: G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\src\app\common\data\reserva.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:643:23)
at plugin.done.then (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/recursos/component/agenda-form-reserva-list.component.ts 8:16-52
@ ./src/app/recursos/component/agenda-form.component.ngfactory.js
@ ./src/app/campanyas/campanya.module.ngfactory.js
@ ./$$_lazy_route_resource async
@ ./~/@angular/core/esm5/core.js
@ ./src/main-aot.ts
In my case it was not exactly a casing issue but also an import that had to be fixed.
Using ngx-clipboard I had to change the import from import { ClipboardModule } from 'ngx-clipboard/index';
to import { ClipboardModule } from 'ngx-clipboard/dist';.
I have exactly the same problem if I run ng serve from symbolically linked folder (~/src/... in my case).
However, if I run ng serve from the real folder (/c/src/... in my case), everything is fine.
This issue caused most of the teams in my Enterprise company to drop all their Angular X projects & switch to React based application (because we have a huge shared code-base & there is no easy way to export Angular projects as NPM libraries).
I actually liked Angular that's too bad :\ hope this will be solved soon enough before the point of no return.
I had the same problem in one of my npm modules.
I've solved it by adding a declaration files *.d.ts.
I think you should open an issue to the npm module that your using.
@SaltyDH I had a similar issue but found that it was a result of the version of TypeScript that I had installed. I had ^2.5.1 in my package.json and thought I was using 2.5.3. Turns out I had 2.5.1 installed and it was causing the issue.
I changed my dependency to 2.5.x, the same as the Angular repo
Did an npm install
Verified with npm list typescript that I had 2.5.3 installed
@rkrisztian I had the issue just with ng test.
Add ../ in the include paths in the tsconfig.spec.json resolve my problem.
It seems the inheritance of the tsconfig.json doesn't work for the paths, because the base directory isn't the same.
I have a large enterprise app with the "code sharing" setup mentioned above. Essentially there are lazy routes defined that load feature modules, these modules are shells that in turn import from node_modules where the actual feature modules (in module.ts files via index.ts barrels) are pulled in from our internal npme/nexus. Worked like a champ with Ng4 and enabled our distributed development across multiple teams/repos.
With Ng5, after updating the tsconfig files, it will work in JiT (ng serve and ng build).
AoT will build, but when the app is started a "Uncaught TypeError: ctor is not a constructor" is thrown immediately .
Seems silly that we have to include files that are normally part of the build. Currently my whatever is complaining that " \src\main.ts is missing from the TypeScript compilation." but that's the very very first file angular looks at, so that seems strange.
Well we’re not ‘shipping’ anything. This is an internal library for which we have control over which compliler we use. So packaging for distribution is a unnecessary step. We did figure out how to import it with straight .ts files, as the SO question was answered satisfactorily.
@filipesilva. I am facing the same issue Just to summarize, we have a large project. So 1 project is used as library and sits in the node_modules folder. When on Angular 4 it works fine but when upgraded it is throwing me this error: Module build failed: XXX file is missing in Typescript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. I have read this whole ticket and specially implemented what you suggested of manually adding it in tsconfig.json. But when I do that it prompts me a different error: Unknown compiler option 'include' and 'exclude'. It would be great help if you could get me out of this issue. Thank you in advance. Just to reiterate I have read through the whole blog and tried different solutions it does not seem to work. Again Thank you in advance.
@andi-wr Thank you for the solution but it still does not work. It gives me whole lot of errors. Saying cannot find name 'describe'; cannot find name 'beforeEach' etc in all the files. This is a huge list of errors.
@filipesilva
I am getting the below error and the third party literary do not have .ts file. can you help
ERROR in ./node_modules/agm-direction/src/agm-direction.module.ts
Module build failed: Error: D:\TandT\TandTSrc\node_modules\agm-direction\src\agm-direction.module.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 (D:\TandT\TandTSrc\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:656:23)
at plugin.done.then (D:\TandT\TandTSrc\node_modules@ngtools\webpack\src\loader.js:467:39)
at
at process._tickCallback (internal/process/next_tick.js:169:7)
@ ./node_modules/agm-direction/index.js 6:9-46
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
I don't know if people are still having this problem - here's how I fixed the issue.
I have 2 tsconfig.json files, one at the root of the app, and the other inside the src folder (one level down from the root) named tsconfig.app.json that extends the main tsconfig.json. I explicitly added the package that I needed that wasn't being transpiled by Typescript in the "include" array, and like a lot of people here I was getting the *.spec.ts files included despite having them in "exclude" option, so I removed it from the tsconfig.json. The fix was adding the "exclude" option to the second (extended) tsconfig.app.json file. Doing that fixes the Typescript errors and lets me run ng serve without issue.
For some reason adding the exclude in the extended tsconfig (tsconfig.app.json) file is the only way I was able to get it to not complain about the spec files.
Based on the comments from @filipesilva this may still be a bug but it worked for me. Hopefully this helps anyone facing the same issue.
Reacted by Buzz Zhang, Shabih, Amin Mahfouz, Igor Plaksiy and asmith2306
we used to compile all files, essentially ignoring what tsconfig listed. This was a bug
IMHO, the new behavior of failing when the compiler wasn't asked to compile a file it wasn't supposed to compile in the first place is also a bug.
we don't really support using incorrectly packaged libraries
npm link is supported by, well, NPM, so it seems odd that angular doesn't. In particular, I've got this in in my .npmignore:
*.ts
!*.d.ts
So that TypeScript files are not included when I npm publish. Perhaps angular could also respect .npmignore files ,and only complain when a .ts file that would be included in a published package is encountered. This would resolve the problems that devs who co-develop an angular site and a related npm package have with this new behavior.
I realize that my situation may be more complicated than most. I've got an angular app and 3 independent NPM packages that I'm working on, where my app depends on all 3 packages, and one of the packages depends on the other two. Two days of googling, RTFMing, and trying every combination of exclude:["foo","bar","bat"] haven't worked for me. (thought oddly "including" them does work, though it brings up another host of other errors b/c I use different versions fo pacakges in my dependences, so there are collisions with the typings between my app's dependencies and my dependencies dependencies.)
In the end, I npm pack'ed my dependencies, installed them in my app from the built .tgz files, put build scripts in my package.json for all my dependencies like so:
all because of this paternalisticl error, that obstructs the use of npm link -- which is a mode of development tool explicitly supported by NPM!
In future, can this be warning instead of an error, or perhaps add a cli flag indicating that no error should be raised just because angular wasn't asked to compile every .ts file it can find?
Workaround:
This error is thrown when loading .js files and .map files, and not when deciding which .ts files to compile. Hence, if:
you are using npm link or npm i file:/my/other/package to co-develop an angular app and a node package and
you have "sourceMap": true, in the compiler options of your linked package, and
you have called tsc in your linked repo,
then you can go to the line that threw the error, which is listed in the output from ng serve and comment out the line throw new Error(msg);, and you're off to the races.
The downside to this workaround is that while your ng-serveer will reload your app every time you make changes in your dependency projects -- but it won't compile them and you'll have to restart ng-serve after calling tsc in your dependency in order for updates in your dependencies to be picked up.
In short, the workaround sucks, but at least it doesn't prevent you from doing development on separate projects with separate dependencies and typings.
The tsconfig file is what determines what TS files are compiled. The error you are getting means that the files mentioned are not being compiled as explained in the following comment #8284 (comment).
Having all the feedback in a single thread makes it hard to get meaningful reports, or to inform people of what versions the regressions that affect them were fixed.
Having so many hidden comments makes it hard for people to find the information in anything but the latest comments. But on the other hand I don't think most people would go through all of the comments anyway. New users that see this thread mostly read the first and latest comments and lose things said in between.
So for the reasons stated above (high volume of comments, hidden comments, hard to report and inform people) I'm also locking this issue to prevent this comment from being lost as new comments come in.
If you are still experiencing an issue please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
Activity
filipesilva commentedon Nov 2, 2017
@MakesNine so if you try having a file with just interfaces it's still fine in a new project? Hm... I've heard of problems with casing. Are your imports perhaps using the wrong casing? Does it still happen if you add a non-interface export to that file? That seems to be a lazy route, perhaps it's related. Can you try making that route not lazy?
@KevinFernandes this definitely shouldn't happen to all library packages, unless somehow you're just using packages that weren't packaged well. Can you give me examples of a couple of these packages? I can have a look.
MakesNine commentedon Nov 2, 2017
@filipesilva yest, I can build a new project and import a file with only interfaces from a lazy loaded module. I will double check the casing and try the original app with a non lazy route for the module where the error originates.
MakesNine commentedon Nov 2, 2017
@filipesilva I have added an import and exported a function from the file refusing to be part of the compilation and it didn't help.
I have changed all the routes, in app-routing.module.ts, that have components importing type definitions from that file so that they wouldn't be lazy loaded and the app compiled, but didn't work. I had forgotten to import the modules, in app.module.ts', that contained the components now used in the non lazy loaded routes. Once I add the required imports in app.module.ts, I get the same problem that I get with lazy loaded routes. I have also checked casing and all seems ok on that front.
rolaveric commentedon Nov 2, 2017
Thanks @filipesilva - that explains my issue.
I tried explicitly including my internal libraries using
include, but that's giving me other grief (picking up on test suites, despite usingexclude). So I'll do it properly and have them expose compiled code.I knew it was something I should do, but with them only being used internally by the company, I let it slide.
Thanks again to you and all the contributors for your hard work on Angular CLI - it's an excellent tool and very much appreciated.
stuartwk commentedon Nov 3, 2017
I was having the same issue after updating. Like some other people, the ts files were all part of the standard CLI structure tree. Turned out it was a case sensitivity issue for me. I had accidentally written something like...
import { Comment } from './Comment'while in other componentsimport { Comment } from './comment'. Running a normal build would throw me a helpful warning before erroring out, but building for prod only showed me the "Please make sure it is in your tsconfig via the 'files' or 'include' property" error. Fixed the casing issue and prod builds for me fine.MakesNine commentedon Nov 3, 2017
I finally got my app to compile. It turned out that it was a casing issue indeed.
The error I was getting was:
ERROR in ./src/app/core/StateManagement/models/genericCourse.models.ts
And the solution is to change the related import to:
./src/app/core/stateManagement/models/genericCourse.models.ts
Curiously, I have other files in that folder that were also imported with StateMangement in the path and the compiler didn't complain.
Thansk for your input @filipesilva
prasadkadiyala commentedon Nov 3, 2017
We got the same problem when importing the modules.
chore(client): distribute shared libs in JS via dist
filipesilva commentedon Nov 3, 2017
@MakesNine that is weird indeed, and I'm not really sure why that happens... I expected all bad paths to throw an error somehow. Will keep an eye out for more such casing reports.
KevinFernandes commentedon Nov 3, 2017
@filipesilva I see hundreds of errors so its hard to sort through them. From what I can see at the moment it's all of "my" library packages, packages that we build and publish to a local repository. We package all of the .ts files as well as a webpacked bundle file.
When we were building with SystemJS it made sense that we had to explicitly specify all of the bundles to include from node_modules, but with the CLI it seemed to just work without any extra specifications. It made our lives a thousand times easier. But now it seems what we thought was a feature was actually a bug in CLI and possibly something that we are doing wrong (and have been for more than a year now).
So what exactly is the problem? Is it that the CLI was compiling the .ts files that we had in our library packages and so did not need the bundles? If that is the case then how do we now tell the CLI to use the bundle? Is it something to do differently when packaging the library bundles or is it some angular-cli.json configuration we have to change.
Sorry, up until now we had though we had finally figured out this JavaScript eco system, but now it seems we still have some things to learn.
filipesilva commentedon Nov 3, 2017
@KevinFernandes ok so that it happens on your local libs makes sense considering the other reports in this issue. Yes, before it seems like the CLI was compiling the TS in your local libraries, which was just a ticking time bomb really.
The way to address this in your codebase really depends on how you build your libs... Do you use an existing library to do it? I think a lot of users use https://github.com/dherges/ng-packagr and seem to be happy with it. I haven't myself though.
chore(client): distribute shared libs in JS via dist
chore(client): distribute shared libs in JS via dist
chore(client): distribute shared libs in JS via dist
chore(client): distribute shared libs in JS via dist
emazv72 commentedon Nov 6, 2017
I can report a similar issue:
I have a standard, cli generated, folder structure ( Windows platform )
I simply share some modules between different applications at the source level.
Under src there are the following folders:
Under packages:
Each folder is a module ( proper module.ts ) and has an index.ts for the exports.
tsconfig.json looks like this:
An import statement looks like this:
import { DataSourceResult, NotificationService } from '@combo-components/core';It worked fine till angular 4.x and cli 1.4.x
After upgrading to 5.0 & cli 1.5.0,
ng buildfails with the following error:ERROR in ../catol/combo-components/src/index.ts
Module build failed: Error: C:\Users...\workspace\catol\combo-components\src\index.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/app.module.ts 13:0-63
@ ./src/main.ts
@ multi ./src/main.ts
Casing checked, also added the include property suggested by @filipesilva
The error changes slightly:
ERROR in ./src/main.ts
Module build failed: Error: C:\Users...\workspace\playground\src\main.ts is not part of the compilation output. Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:629:23)
at plugin.done.then (C:\Users...\workspace\playground\node_modules@ngtools\webpack\src\loader.js:467:39)
at process._tickCallback (internal/process/next_tick.js:109:7)
@ multi ./src/main.ts
ERROR in ./src/polyfills.ts
...
Adding main&polyfill to the include path doesn't help either.
zhekaus commentedon Nov 6, 2017
The same issue with fresh-created app using
ng newAngular CLI: 1.5.0
Node: 6.10.3
OS: win32 x64
Angular: 5.0.0
scottieslg commentedon Nov 6, 2017
I was having this issue and it was a case issue.
I was trying to do this:
import { IJobModel, JobModel } from "./jobModels/job.model";which should be
import { IJobModel, JobModel } from "./JobModels/job.model";(./jobModels was camel cased instead of upper case)
sandangel commentedon Nov 7, 2017
have you tried with --preserve-symlinks flag? angular/angular#20091
emazv72 commentedon Nov 7, 2017
@sandangel Thank you that worked for me, no need to add the 'include' property in tsconfig.json
After upgrade, either run
ng serve --preserve-symlinksor update
.angular-cli.jsonif you have symlinks in the source tree.
ag-susini commentedon Nov 7, 2017
I'm using a 3rd party library from Google called api-ai-javascript which is installed in the node_modules folder, using
ng serve --preserve-symlinksdoes not work and neither does updating myangular-cli.jsonfile, I have to explicitly update my tsconfig file withincludein order to overcome the following errorOnly after updating to Angular 5.0.0 and Angular-cli 1.5.0 did the issue start occurring.
SamD commentedon Nov 7, 2017
I'm also seeing the issue after upgrading to Angular 5 and cli 1.5.0 with a third-party logger module that had no issues previously.
Tried suggested methods posted here still the same error.
ERROR in ./node_modules/angular2-logger/app/core/level.ts Module build failed: Error: node_modules/angular2-logger/app/core/level.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.MrVintage710 commentedon Nov 8, 2017
I am have the same error, although mine came about after I imported the 'Input' class from '@angular/core'.
import {Component, OnInit, ViewEncapsulation, Input} from '@angular/core';After I used the
@Input()on the variablehero: Heroit breaks. If I don't type hero like@Input() heroit is fine, but as soon as I add: Hero;it breaks.michaelwaihenya commentedon Nov 8, 2017
@scottieslg pointed me in the right direction. (Typo in path casing). Additionally I had several backticks (`) in my compoments that were compiling before. single quotes (') resolved the issue.
little-boy commentedon Nov 9, 2017
I encountered the problem with a project having a Symfony like architecture.
Meaning there is :
./tsconfig.json
./src/tsconfig.app.json
./src/SomeFolder/app/*.ts...
There are dependencies between each bundles.
One of the dependencies was thrown in "...is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property"
I solved the problem by including every ts files as suggested by @filipesilva but in a different order.
=> Bundle B needed by Bundle A & C
so tsconfig.app.json like :
{ "include": [ "pathToBundleB/**/*.ts", "pathToBundleA/**/*.ts", "pathToBundleC/**/*.ts", ] }instead of :
{ "include": [ "pathToBundleA/**/*.ts", "pathToBundleB/**/*.ts", "pathToBundleC/**/*.ts", ] }That's kinda weird. Looks like @ngtools/webpack/src/angular_compiler_plugin.js:624:23), the function this._compilerHost.fileExists is looking for bundles loaded before, and not after..
matt-psaltis commentedon Nov 10, 2017
I'm getting this error for files that are referenced in our app.module.ts. Its almost like this file is treated differently in some way because its the module referenced in the AngularCompilerPlugin options??? I've tried manually adding the module to the tsconfig files section but that hasn't resolved it.
sbkpilot1 commentedon Nov 10, 2017
We are having the same issue. We have a private repo where we have published a library that we use. We have this lib as a dependency in our client, when compiling in Angular 5 we get the following error but ONLY in JIT mode, if we use a ng serve --aot or ng build --aot or --prod it works fine. Not sure what is the issue here. We are using Angular 5.0.1 with CLI 1.5.0
We tried using includes in tsconfig, while that solves this issue it generates another different error that my json module declarations are not found which is specified in typings.d.ts (with a declare module "*.json").
rolaveric commentedon Nov 10, 2017
I've managed to resolve the issue I was having by, as per @filipesilva's advice, compiling the TS code from my library and configuring it so my downstream projects could consume it.
I did have a lot of trouble with this though, so I want to share some details in the hope they'll help others with the same frustrations.
Most of the documentation and discussion available frames these repos we're installing via npm as "libraries" in the open source sense of the term: The code is on github, the artifacts are published to npm, and they must be built for general consumption (ie. accounting for different projects with different ES targets).
My situation (which is not unique, from the sound of things) is different in that my "library" is for internal company use only.
To help separate this use case from the "open source library" scenario, I'm going to call what I've got a "shared codebase".
Your starting point should be @filipesilva's
angular-quickstart-librepo.If, like me, you've got a "shared codebase" then you don't need everything from here. The key things you need are:
templateUrlbecomestemplate)ngc, with appropriatetsconfig.jsonsettingsmoduleandtypingsproperties to yourpackage.json, pointing at theindex.jsandindex.d.tsof your compiled code.What you don't need is bundling (Just use the raw
*.jsfiles), and you probably only need a single compile target (ES5 or ES2015).So you can strip down a lot of the
build.jsfile (removing the need for a fair few extra npm dependencies) and ignore references toflatModulein thetsconfig.lib.json.I hope that helps.
jacinto-joao commentedon Nov 11, 2017
This really stressful!
Myself and my team, we have put all energy believing and trusting Angular,
that's this time things will be different not like from angularJs to angular 2.
And we could jump a long time from angularJs to ReactJs or Aurelia or maybe VueJs,
but the love and trust we had it keeps as loving Angular and believing that we won't have same stress like we had from angularJs to angular 2.
Now we already with big projects out there, using third-party open source libraries, which till angular 4.3, everything was fine.
But now in angular 5 with the CLI 1.5, we were expecting the upgrade to be smooth and not having this kind of issue.
So now we're stuck and hoping that the creators of the libraries they update the package.
And the questions come again, should we keep believing that angular will have the success like angularJs had on the past, or now is time to move on trying something different because this is a nightmare, and each version got different stories, and we must signup new courses to learn over.
I'm sorry for my comments, but this how it feels like.
deebloo commentedon Nov 11, 2017
@jjoao07 Sorry you are having trouble. The issue isn't an angular issue it is a typescript issue. To solve it for linked libraries that have typescript shipped in them you can add that to your tsconfig "includes" property. So if you have a folder in your node modules called "my-lib" you can add. The typescript compiler by default does not see the typescript code in node_modules by default (and it shouldn't). I hope this helps.
this is the same as mentioned by @filipesilva and @little-boy
{ "includes": ["node_modules/my-lib"] }sbkpilot1 commentedon Nov 11, 2017
@deebloo if the Typescript compiler shouldn't be looking at ts code in the node modules then perhaps adding an includes is not the best solution for this? Should we be packaging our libraries differently?
deebloo commentedon Nov 12, 2017
@sbkpilot1 overall yes. if you are publishing a module you should only be distributing javascript and the generated type definitions. The solution I mentioned is only a workaround
akkumar commentedon Nov 13, 2017
Adding the following to .npmignore (in addition to 'includ'ing in tsconfig.json, of course) fixes it for me.
malaba03 commentedon Nov 14, 2017
hello guys,
I had the same issue in my project (Angular 5.0.0).
I solved it by deleting the file which causes the problem.
After i created it again and pasting the same code step by step in order to make sure what part of the code cause the problem.
Now everything work.
Hope my solution will help you.
@malaba
JulienBourgain commentedon Nov 14, 2017
@filipesilva I understand your arguments, but why release a breaking change in a minor version ?!
It's better to add a warning in this version and correct this behaviour in 2.0.0
do not distribute ts in npm (#75)
Jesu26 commentedon Nov 15, 2017
Hi ,
I am also facing the same problem.
while compiling the solution via ng serve -o after angular 5 update this issue occurs.
i have used npm link to link all my modules.
ERROR in ./platform/userModule/app/app.module.ts
Module build failed: Error: E:\temp\trunk\platform\userModule\app\app.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (E:\temp\trunk\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (E:\temp\trunk\node_modules@ngtools\webpack\src\loader.js:467:39)
at
@ ./src/$$_lazy_route_resource lazy
@ ./node_modules/@angular/core/esm5/core.js
@ ./src/main.ts
@ multi ./src/main.ts
usernameisMan commentedon Nov 16, 2017
i also met the question ,
ERROR in ./src/app/hero.ts
Module build failed: Error: F:\lenleeWorkProject\angular\angular-tour-of-heroes\src\app\hero.ts is not part o
f the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (F:\lenleeWorkProject\angular\angular-tour-of-heroes\node_module
s@ngtools\webpack\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (F:\lenleeWorkProject\angular\angular-tour-of-heroes\node_modules@ngtools\webpack\sr
c\loader.js:467:39)
at
@ ./src/app/hero-detail/hero-detail.component.ts 11:0-31
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
============================
i am check all the hero.ts reference, The discovery problem appears on the file path
is Uppercase the Hero Instead of hero 。
so why path error not prompting?
Instead, it returns to normal after manually triggering the save
Angular CLI: 1.5.0
Node: 8.4.0
OS: win32 x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular / cli: 1.5.0
@Angular-devkit / build-optimizer: 0.0.33
@Angular-devkit / core: 0.0.20
@Angular-devkit / schematics: 0.0.35
@ngtools / json-schema: 1.1.0
@ngtools / webpack: 1.8.0
@schematics / angular: 0.1.3
typescript : 2.4.2
webpack : 3.8.1
abel-bzz commentedon Nov 20, 2017
Hello, I came across the same issue using angular 5.0.1 and CLI 1.5 :
At first I had a case issue that I solved and it worked fine for a while but the error came back somehow later.
I tried what @sandangel suggested by using the flag
--preserve-symlinksbut it did not worked.Finally, I found another issue (#20091) where @stephanecot suggested the use of
--aotand it works fine, although I have no idea why...As the flag suggests, it use the Ahead of time compilation which can be unwanted.
I hope it will help someone.
khalid-halo commentedon Nov 23, 2017
Tried workarounds mentioned in this thread, dosen't seem to help. Still getting the same error.
ERROR in ./node_modules/angular2-isotope/index.tsHow can I compile the library locally to continue development for the time being?
misaizdaleka commentedon Nov 23, 2017
What I did with my library is I moved it to the src folder and included it from there. Not a clean solution, but it'll work until the Angular guys figure this one out.
rychkog commentedon Nov 25, 2017
I have same symptoms like @nueko has. When one of my dependencies is linked via symlink and I invoke
ng build --prod --build-optimizer- then it fails.--preserve-symlinkshelps to fix this particular case:ng build --prod --build-optimizer --preserve-symlinksmilosmijakovac commentedon Nov 29, 2017
Current set :
Angular-cli : 1.5.4
npm 5.5
node 8.9
This is my problem:
HollisTech commentedon Dec 3, 2017
adding: to the defaults section of .angual-cli.json
,
"build": {
"preserveSymlinks": true
}
corrects this malfunction. 100% reproducible with generated app.
milosmijakovac commentedon Dec 3, 2017
@HollisTech
it shows same warning! : (
ERROR in ./src/app/hero.ts ....RyannGalea commentedon Dec 7, 2017
Yep, same issue here with upgrading to 5.1, never had this issue before now.
My include ended up looking like this to bring everything in I needed for compilation.
"include": [ "**.ts", "app/**.ts", "app/**/**.ts", "../node_modules/angular2-semantic-ui/components/**/**.ts" ]mattytommo commentedon Dec 8, 2017
We're using the "shared codebase" approach @rolaveric is using and I managed to get it to compile and run fine by adding the following include to the tsconfig.json:
That all works great, however if I try and run
ng testI end up with the same build errors that I got before adding our shared codebase to the includes (Module build failed: "{sharedcodebasename}/file.ts" is not part of the compilation output.Now @filipesilva I appreciate you saying this isn't the "proper way to do an NPM package", but for my case (and what looks like a few others in this thread), we have internal company "packages" that we don't want pushing to NPM (we push them to our private Nexus repo) and publishing typescript files as a package is exactly what we need. Is there any way that this can be resolved? I understand the rationale behind the change in compilation behaviour, but it seems to be causing many unintended headaches.
rkrisztian commentedon Dec 11, 2017
@mattytommo, instead of editing
tsconfig.jsonlike that, you can add the include(s) intotsconfig.app.json+tsconfig.spec.json(prefixed with../of course). I know that's slightly uglier. :)mattytommo commentedon Dec 13, 2017
@rkrisztian I must have tried it in those files 100 times, but I don't think I actually prefixed with ../ because adding that to the spec.json file works!!
So, essentially, as long as you put the include within the spec.json (for the tests) and the tsconfig.json (or .app.json), the build and tests work. Thanks again rkrisztian.
estebanluengo commentedon Dec 13, 2017
I don't think is a problem of angular-cli. I compile my projects directly with webpack and my own config files and I have the same problem if a use AOT option with Angular 5.x.x but it's perfect in Angular 4.x.x. But if I don't use AOT option the compilation is fine even in Angular 5.x.x.
It's very strange but the problem is that some DTOs classes are not included in the compilation process. I have 15 DTO classes in src\app\common\dto directory and 16 POJO classes in src\app\common\data directory and some of them are not included in the compilation process. I reviewed the Javascript files generated by the AOT compiler and they don't appear in any place. But if I don't use AOT or I use Angular 4.x.x all the classes are included in the compilation process.
Maybe the bug is in the Ahead-of-Time compiler in Angular 5.x.x or in the Webpack Plugin: @ngtools\webpack
ERROR in ./src/app/common/dto/SolicitanteDTO.ts
Module build failed: Error: G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\src\app\common\dto\SolicitanteDTO.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:643:23)
at plugin.done.then (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/citas/component/cita-form-new.component.ts 19:23-65
@ ./src/app/citas/cita.module.ngfactory.js
@ ./$$_lazy_route_resource async
@ ./~/@angular/core/esm5/core.js
@ ./src/main-aot.ts
ERROR in ./src/app/common/dto/SolicitanteCampoDTO.ts
Module build failed: Error: G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\src\app\common\dto\SolicitanteCampoDTO.ts is not part of the compilation. Please make sure it is
in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:643:23)
at plugin.done.then (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/citas/component/cita-form-new.component.ts 18:28-75
@ ./src/app/citas/cita.module.ngfactory.js
@ ./$$_lazy_route_resource async
@ ./~/@angular/core/esm5/core.js
@ ./src/main-aot.ts
ERROR in ./src/app/common/data/reserva.ts
Module build failed: Error: G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\src\app\common\data\reserva.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:643:23)
at plugin.done.then (G:\Proyectos\BITCITA\bitcita-front\src\main\frontend\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./src/app/recursos/component/agenda-form-reserva-list.component.ts 8:16-52
@ ./src/app/recursos/component/agenda-form.component.ngfactory.js
@ ./src/app/campanyas/campanya.module.ngfactory.js
@ ./$$_lazy_route_resource async
@ ./~/@angular/core/esm5/core.js
@ ./src/main-aot.ts
rgantla commentedon Dec 13, 2017
I have faced the same issue and turns out, in my case it was a Casing Issue.
I had an import like so: import { Employee } from '../../../models/employeeType.model'; in more than one component.
One of the components that had this import had a different casing in the file path like import { Employee } from '../../../models/EmployeeType.model';
Changing the file path for the import to be consistent across the application fixed the issue for me.
milosmijakovac commentedon Dec 13, 2017
@rgantla wooww..I wondered how long it would take (centuries) to figure out where I was wrong .
It was exactly Casing issue!
Very thanks!
estebanluengo commentedon Dec 14, 2017
@rgantla OMG!!. That was exactly the problem. It was a Casing Issue. Thanks!!
sbley commentedon Dec 14, 2017
In my case it was not exactly a casing issue but also an import that had to be fixed.
Using ngx-clipboard I had to change the import from
import { ClipboardModule } from 'ngx-clipboard/index';to
import { ClipboardModule } from 'ngx-clipboard/dist';.Hope that helps someone in the same situation.
zhekaus commentedon Dec 18, 2017
I have exactly the same problem if I run
ng servefrom symbolically linked folder (~/src/...in my case).However, if I run
ng servefrom the real folder (/c/src/...in my case), everything is fine.bnohad commentedon Dec 20, 2017
This issue caused most of the teams in my Enterprise company to drop all their Angular X projects & switch to React based application (because we have a huge shared code-base & there is no easy way to export Angular projects as NPM libraries).
I actually liked Angular that's too bad :\ hope this will be solved soon enough before the point of no return.
fix(@ngtools/webpack): improve missing TS file error message
fix(@ngtools/webpack): improve missing TS file error message
fix(@ngtools/webpack): improve missing TS file error message
fix(@ngtools/webpack): improve missing TS file error message
fix(@ngtools/webpack): improve missing TS file error message
fix(@ngtools/webpack): improve missing TS file error message
fix(@ngtools/webpack): improve missing TS file error message
packaging .ts files in npm package causes issues
ranbuch commentedon Jan 5, 2018
I had the same problem in one of my
npm modules.I've solved it by adding a declaration files
*.d.ts.I think you should open an issue to the
npm modulethat your using.txinfo commentedon Jan 8, 2018
I left a comment #6195 (comment) that might help some people resolve issues around this.
sternetj commentedon Jan 8, 2018
@SaltyDH I had a similar issue but found that it was a result of the version of TypeScript that I had installed. I had
^2.5.1in my package.json and thought I was using 2.5.3. Turns out I had 2.5.1 installed and it was causing the issue.2.5.x, the same as the Angular reponpm installnpm list typescriptthat I had 2.5.3 installedng serveand my app built without issuetobat50 commentedon Jan 11, 2018
@rkrisztian I had the issue just with
ng test.Add
../in the include paths in thetsconfig.spec.jsonresolve my problem.It seems the inheritance of the
tsconfig.jsondoesn't work for the paths, because the base directory isn't the same.BBaysinger commentedon Jan 25, 2018
I have an issue with the workaround. My SO question: https://stackoverflow.com/questions/48449948/how-to-import-repo-with-uncompiled-typescript-in-angular-5-x
AndreiLucaci commentedon Jan 29, 2018
Also, if working with ASP.Core 2.0 template, the
srcfolder is renamed toClientAppso in that case you should add it to yourtsconfig.jsonfile:b-johnse commentedon Jan 30, 2018
I have a large enterprise app with the "code sharing" setup mentioned above. Essentially there are lazy routes defined that load feature modules, these modules are shells that in turn import from node_modules where the actual feature modules (in module.ts files via index.ts barrels) are pulled in from our internal npme/nexus. Worked like a champ with Ng4 and enabled our distributed development across multiple teams/repos.
With Ng5, after updating the tsconfig files, it will work in JiT (ng serve and ng build).
AoT will build, but when the app is started a "Uncaught TypeError: ctor is not a constructor" is thrown immediately .
stofte commentedon Jan 31, 2018
Seems silly that we have to include files that are normally part of the build. Currently my whatever is complaining that " \src\main.ts is missing from the TypeScript compilation." but that's the very very first file angular looks at, so that seems strange.
Oh well.
plamf commentedon Feb 2, 2018
@filipesilva
What exactly do you mean? We use ng-packagr, which ships *.d.ts files and we thought that is the right way to deliver a package.
benelliott commentedon Feb 2, 2018
@plamf Shipping *.d.ts is fine, it is shipping the original source *.ts files that is not.
BBaysinger commentedon Feb 4, 2018
Well we’re not ‘shipping’ anything. This is an internal library for which we have control over which compliler we use. So packaging for distribution is a unnecessary step. We did figure out how to import it with straight .ts files, as the SO question was answered satisfactorily.
ORESoftware commentedon Feb 15, 2018
I have this issue....this issue sucks :(
this is how I solved it for local development:
https://stackoverflow.com/questions/48797135/missing-ts-files-due-to-npm-link/48798373#48798373
kaushikdighe commentedon Feb 16, 2018
@filipesilva. I am facing the same issue Just to summarize, we have a large project. So 1 project is used as library and sits in the node_modules folder. When on Angular 4 it works fine but when upgraded it is throwing me this error: Module build failed: XXX file is missing in Typescript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. I have read this whole ticket and specially implemented what you suggested of manually adding it in tsconfig.json. But when I do that it prompts me a different error: Unknown compiler option 'include' and 'exclude'. It would be great help if you could get me out of this issue. Thank you in advance. Just to reiterate I have read through the whole blog and tried different solutions it does not seem to work. Again Thank you in advance.
kaushikdighe commentedon Feb 20, 2018
@andi-wr Thank you for the solution but it still does not work. It gives me whole lot of errors. Saying cannot find name 'describe'; cannot find name 'beforeEach' etc in all the files. This is a huge list of errors.
princeprathap commentedon Mar 1, 2018
@filipesilva
I am getting the below error and the third party literary do not have .ts file. can you help
ERROR in ./node_modules/agm-direction/src/agm-direction.module.ts
Module build failed: Error: D:\TandT\TandTSrc\node_modules\agm-direction\src\agm-direction.module.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 (D:\TandT\TandTSrc\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:656:23)
at plugin.done.then (D:\TandT\TandTSrc\node_modules@ngtools\webpack\src\loader.js:467:39)
at
at process._tickCallback (internal/process/next_tick.js:169:7)
@ ./node_modules/agm-direction/index.js 6:9-46
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
tapaz1 commentedon Mar 5, 2018
I don't know if people are still having this problem - here's how I fixed the issue.
I have 2 tsconfig.json files, one at the root of the app, and the other inside the src folder (one level down from the root) named tsconfig.app.json that extends the main tsconfig.json. I explicitly added the package that I needed that wasn't being transpiled by Typescript in the "include" array, and like a lot of people here I was getting the *.spec.ts files included despite having them in "exclude" option, so I removed it from the tsconfig.json. The fix was adding the "exclude" option to the second (extended) tsconfig.app.json file. Doing that fixes the Typescript errors and lets me run ng serve without issue.
Here is tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
},
"include": [
"./src",
"node_modules/your_package"
]
}
And tsconfig.app.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"../node_modules/your_package/**/*.spec.ts"
]
}
For some reason adding the exclude in the extended tsconfig (tsconfig.app.json) file is the only way I was able to get it to not complain about the spec files.
Based on the comments from @filipesilva this may still be a bug but it worked for me. Hopefully this helps anyone facing the same issue.
fengerzh commentedon Mar 9, 2018
@tapaz1 By following your instruction, I got it work. I added a section of
includeintsconfig.jsonto include the failed module as below:"include": ["./src", "node_modules/@jaspero/ng2-select"]then build success. Thank you!
jdthorpe commentedon Apr 12, 2018
IMHO, the new behavior of failing when the compiler wasn't asked to compile a file it wasn't supposed to compile in the first place is also a bug.
npm linkis supported by, well, NPM, so it seems odd that angular doesn't. In particular, I've got this in in my.npmignore:So that TypeScript files are not included when I
npm publish. Perhaps angular could also respect.npmignorefiles ,and only complain when a.tsfile that would be included in a published package is encountered. This would resolve the problems that devs who co-develop an angular site and a related npm package have with this new behavior.I realize that my situation may be more complicated than most. I've got an angular app and 3 independent NPM packages that I'm working on, where my app depends on all 3 packages, and one of the packages depends on the other two. Two days of googling, RTFMing, and trying every combination of
exclude:["foo","bar","bat"]haven't worked for me. (thought oddly "including" them does work, though it brings up another host of other errors b/c I use different versions fo pacakges in my dependences, so there are collisions with the typings between my app's dependencies and my dependencies dependencies.)In the end, I
npm pack'ed my dependencies, installed them in my app from the built.tgzfiles, put build scripts in mypackage.jsonfor all my dependencies like so:all because of this paternalisticl error, that obstructs the use of
npm link-- which is a mode of development tool explicitly supported by NPM!In future, can this be warning instead of an error, or perhaps add a cli flag indicating that no error should be raised just because angular wasn't asked to compile every
.tsfile it can find?Workaround:
This error is thrown when loading
.jsfiles and.mapfiles, and not when deciding which.tsfiles to compile. Hence, if:npm linkornpm i file:/my/other/packageto co-develop an angular app and a node package and"sourceMap": true,in the compiler options of your linked package, andtscin your linked repo,then you can go to the line that threw the error, which is listed in the output from
ng serveand comment out the linethrow new Error(msg);, and you're off to the races.The downside to this workaround is that while your
ng-serveer will reload your app every time you make changes in your dependency projects -- but it won't compile them and you'll have to restartng-serveafter callingtscin your dependency in order for updates in your dependencies to be picked up.In short, the workaround sucks, but at least it doesn't prevent you from doing development on separate projects with separate dependencies and typings.
fix(@ngtools/webpack): improve missing TS file error message
Important to work with shared as npm link: "preserveSymlinks": true
mpilarcastillejo commentedon Sep 21, 2018
add in tsconfig.app
"baseUrl": ""
for
"baseUrl": ""
alan-agius4 commentedon Jan 7, 2019
Hi all,
This thread was opened a while ago.
The tsconfig file is what determines what TS files are compiled. The error you are getting means that the files mentioned are not being compiled as explained in the following comment #8284 (comment).
Having all the feedback in a single thread makes it hard to get meaningful reports, or to inform people of what versions the regressions that affect them were fixed.
Having so many hidden comments makes it hard for people to find the information in anything but the latest comments. But on the other hand I don't think most people would go through all of the comments anyway. New users that see this thread mostly read the first and latest comments and lose things said in between.
So for the reasons stated above (high volume of comments, hidden comments, hard to report and inform people) I'm also locking this issue to prevent this comment from being lost as new comments come in.
If you are still experiencing an issue please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.