Angular 5: NPM Link - model/index.ts is not part of the compilation.
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0 Node: 8.7.0 OS: darwin x64 Angular: 5.0.0
Repro steps.
We have a the following folder structure in a git mono-repo
/api (Express Node App) /model (NPM package using NPM Link, contains mostly typescript interfaces) /web (Angular)
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
@rgantla wooww..I wondered how long it would take (centuries) to figure out where I was wrong . It was exactly Casing issue! Very thanks!
@rgantla OMG!!. That was exactly the problem. It was a Casing Issue. Thanks!!
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.
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.
I left a comment https://github.com/angular/angular-cli/issues/6195#issuecomment-355992061 that might help some people resolve issues around this.
@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 typescriptthat I had 2.5.3 installed - Ran
ng serveand my app built without issue
@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 an issue with the workaround. My SO question: https://stackoverflow.com/questions/48449948/how-to-import-repo-with-uncompiled-typescript-in-angular-5-x
Also, if working with ASP.Core 2.0 template, the src folder is renamed to ClientApp so in that case you should add it to your tsconfig.json file:
{
"compilerOptions": {
// stuff
},
"include": [
"./ClientApp/**/*.ts"
]
}
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.
Oh well.
@filipesilva
You have TS files in your node_modules. This really goes against how libraries should be packaged: libraries should never ship their source .ts files.
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.
@plamf Shipping *.d.ts is fine, it is shipping the original source *.ts files that is not.
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.
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
@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