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 on file "is missing from the TypeScript compilation" when invoking ng build or ng serve #9523

Closed
nuno-barreiro opened this issue Feb 6, 2018 · 16 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@nuno-barreiro
Copy link

I have the following folder/file structure on a sample angular5 application created using angular-cli:

ngsample
| tsconfig.json
| src
| | main.ts
| | tsconfig.app.json
| | app
| | | app.module.ts
| | model
| | | index.ts
| | | person.ts
| | services
| | | index.ts
| | | restclient.service.ts

When trying to do a "ng build" or "ng serve" I'm getting the below error:

ERROR in ./app/model/person.ts Module build failed: Error:
C:\Repos\ngsample\src\app\model\person.ts is missing from the
TypeScript compilation. Please make sure it is in your tsconfig via
the 'files' or 'include' pproperty.
at AngularCompilerPlugin.getCompiledFile (C:\Repos\ngsample\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:662:23)
at plugin.done.then (C:\Repos\ngsample\node_modules@ngtools\webpack\src\loader.js:467:39)
@ ./app/model/index.ts 2:0-28 @ ./app/services/restclient.service.ts
@ ./app/services/index.ts @ ./app/app.module.ts @ ./main.ts @ multi
./main.ts

Already found a bunch of articles suggesting to do "ng serve --preserve-symlinks" or to modify the "tsconfig.json" and/or "tsconfig.app.json" to include all the .ts files found under src/app folder. None of the approaches I found on my research seems to work.

Also made sure I don't have a typo and I'm sure that is not the problem right now.

BTW, the index.ts files under "model" and "services" are just exporting all the classes under those folders, such as:

 // model/index.ts
 export * from "./person"
 
 // services/index.ts
 export * from "./restclient.service"

Any ideas of other approaches that I can test to see if I can compile the application correctly?

Versions used:

// packages.json
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/cli": "1.6.7",
"typescript": "^2.6.0"

// node -v
v6.11.3

// ng -v
@angular/cli: 1.6.7
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.7
@schematics/angular: 0.1.17
typescript: 2.6.2
webpack: 3.10.0
@clydin clydin added comp: cli/build needs: repro steps We cannot reproduce the issue with the information given labels Feb 6, 2018
@nuno-barreiro
Copy link
Author

I believe this issue can now be closed. There was indeed a typo in one of the TS imports but not on any of the files that the error was indicating but on another ts model file that was referencing the person.ts.

I was able to found this after trying to clone the project into a different machine and compiling it.

Curious enough is that, despite having build errors and being the same project, the messages between the two machines were quite different.

@Mctalian
Copy link

To add my experience, I had an error like this but it ended up being an issue of case sensitivity.

On my machine, it showed a folder as models but on our CI build machine it had the folder as Models

As a result, one of the .ts files showed up on the build server as not being included in Typescript compilation but on all other machines that I tested it on, it worked just fine.

Apparently my git config settings were set to ignore case. I spent 6 hours debugging this issue, so hopefully I can save a few people some time.

@ORESoftware
Copy link

ORESoftware commented 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

@Diego2357
Copy link

Diego2357 commented Mar 6, 2018

It was same to me... I could figured it out when I executed ng build --base-href=/MyAppWEB/, and it shows me where the TS export problem was.

@cedvdb
Copy link

cedvdb commented Apr 2, 2018

It was also an issue with an import written has ./Store instead of ./store

@danemesis
Copy link

@cedvdb, Thanks, it fixed my problem.

@PRATHYUSH-DOM
Copy link

It was also an issue with an import written has ./Store instead of ./store

Correct answer...

@slartidan
Copy link

I am facing this issue when I am using environment specific providers.

@NishantITRE
Copy link

NishantITRE commented Jul 19, 2018

@ORESoftware Thank you so much for the solution. I have fixed the issues.

Follow link help me to fix : https://stackoverflow.com/questions/48797135/missing-ts-files-due-to-npm-link/48798373#48798373

@vivekjoshi225
Copy link

I believe this issue can now be closed. There was indeed a typo in one of the TS imports but not on any of the files that the error was indicating but on another ts model file that was referencing the person.ts.

I was able to found this after trying to clone the project into a different machine and compiling it.

Curious enough is that, despite having build errors and being the same project, the messages between the two machines were quite different.

@lusocoding,
What was the exact error / typo ?
I am facing the same issue in a very small project with just 2 components

@nuno-barreiro
Copy link
Author

I believe this issue can now be closed. There was indeed a typo in one of the TS imports but not on any of the files that the error was indicating but on another ts model file that was referencing the person.ts.
I was able to found this after trying to clone the project into a different machine and compiling it.
Curious enough is that, despite having build errors and being the same project, the messages between the two machines were quite different.

@lusocoding,
What was the exact error / typo ?
I am facing the same issue in a very small project with just 2 components

I'm not sure. It was a long time ago. But I think it was a case sensitive issue.

@javajoe1
Copy link

Just for some helpful input, if you create a symlink on windows (mklink /D) and try to compile from the path that link points to, you also see this issue.
Putting a note here for future googlers

@ky-one
Copy link

ky-one commented Dec 23, 2018

For all with the symlink problem, this helps: https://github.com/angular/angular-cli/issues/10735#issuecomment-387636803

@kctang
Copy link

kctang commented Mar 17, 2019

For all with the symlink problem, this helps: https://github.com/angular/angular-cli/issues/10735#issuecomment-387636803

Incorrect link location but if you use the text's location, it works - and it solved my problem (multiple apps in ng projects where I used symlink). So, text is the real link.

@muckee
Copy link

muckee commented Jun 21, 2019

Just in case anyone jumped the gun like me...

I had simply altered the file structure and forgotten to stop/start ng serve, so angular was trying to locate the file in its previous directory.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests