angular-cli: main.ts is missing from de TypeScript compilation
Hello,
I just installed node and tried to use cli. I went with the guide:
`npm install -g @angular/cli
ng new my-project cd my-project ng serve`
aaaaaand… nope:
ERROR in C:/Users/hpelitebook/Documents/github/angularjs/angular2/src/main.ts Module build failed: Error: C:\Users\hpelitebook\Documents\github\angularjs\angular2\src\main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at AngularCompilerPlugin.getCompiledFile (C:\Users\hpelitebook\Documents\github\angularjs\angular2\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23) at plugin.done.then (C:\Users\hpelitebook\Documents\github\angularjs\angular2\node_modules\@ngtools\webpack\src\loader.js:467:39) at <anonymous> ERROR in C:/Users/hpelitebook/Documents/github/angularjs/angular2/src/polyfills.ts Module build failed: Error: C:\Users\hpelitebook\Documents\github\angularjs\angular2\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at AngularCompilerPlugin.getCompiledFile (C:\Users\hpelitebook\Documents\github\angularjs\angular2\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23) at plugin.done.then (C:\Users\hpelitebook\Documents\github\angularjs\angular2\node_modules\@ngtools\webpack\src\loader.js:467:39) at <anonymous>
This is my first time with it and i’m not sure where to look
Thank you!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 33 (2 by maintainers)
Editing angular.json to add following attribute under the node “projects/{yourprojectname}/architect/build/options” should help: “preserveSymlinks”: true
Got this problem as well and got it working by moving to a shorter absolute path (rather than one relative to a symlink).
Here are run down with actual names changed to protect the guilty.
To me they demonstrate the problem isn’t git console; It’s DOS Symbolic Links created using
mklink
, (I guess that long paths would also be an issue though I didn’t test them.)Using;
I did:
Created another project on /d/newproj and tested it worked; It did.
Moved it to my /d/Repos/newproj and went to it and it still worked.
Then vie symlink using ~/Repos/newproj and it Failed; so symlinks are bad
As home (~) has a bit of path length too it I tested this with the symlink on /c/ and it failed again
Git Bash MSYS symlinks are of course DOS
mklink
so tested it in DOS console through the link, and not through the link, and got the same result; symlinks are badJust to be even more pedantic I tested it using cygwin symlinks which are not created using DOS mklink and guess what; IT WORK!!
So once again DOS proves the prophetic nature of it’s own acronym. Bill Gates was truly a visionary oracle when he choose that name 😃
I also ran into this problem when using a DOS symbolic link. When I changed to the physical path of the directory, it built without error.
I’m having the same issue with a newly-generated project using angular-cli version 6.0.3. At first, the project worked fine. After I added some files, I ran “ng serve” and it worked ok. Then I ran “ng build” and it failed. Now “ng serve” is not working either.
Both git bash and windows cmd fail.
UPDATE (confusing): Moving the entire project folder to another path solved my issue. Not sure whether it’s a matter of permissions or long paths, but yeah now it works. I’ll dig deeper into the permission thing and update the comment
@igghera Thank you very much. Shortening the path solved my issue. Before my path was like: “C/user/my document/javascript/angular/project/proj-name” and got build errors. Then I changed to “C/Angular/proj-name” and it compiled and ran successfully.
It’s my first time trying out Angular. You can imagine the frustration. Now I can continue with my lessons.
Having the same issue:
tsconfig.json
tsconfig.app.json
.angular-cli.json
Update: Removing the
"files"
key fromtsconfig.app.json
fixed this issue for me. I believe"files"
is auto-populated by ts if it’s not specified, otherwise it exclusively uses the specified files (as mentioned in the tsconfig docs), which makes sense why it couldn’t find a bunch of stuff.I did just recently do an upgrade of certain Angular packages, but this may be unrelated. I’m also the only non-Windows user to have this issue so far.
npm start
also did the job for meI faced the same problem during
ng serve
butnpm start
solved my problem as it was showing some error in webpack moduleYep, adding (“preserveSymlinks”: true) to the angular.json file got rid of the compiling error regarding main.ts
hmm, maybe not the compiler was still active when I was trying to fix another error and now the error regarding main.ts has returned
Thank you! That does the trick and the serve command works. But as I try the ng commands while I am at a symlinked path, I get the some warnings. The output of “ng serve” looks like this:
The app seems to work correctly, but because of this warnings I am not sure if really everything works. I know, it’s “just” a warning and maybe this is not really relevant because it is only the fesm5 core. But if we could figure out how to prevent this warnings, I would be happy.
To let you have a little bit more informations: OS: win32 x64 Console: git-bash / msys2 Node: 10.13.0 Angular CLI: 7.3.1 Angular: 7.2.5
Do you have any idea why I get this errors?
@AlanCarlyle
you deserve a big praise, thanks so much for this, was struggling for around 2 days where for all my colleagues our project works fine and for me it never built… turns out I was the reason because I always create symlinks to shorten the path… will be more careful with that in the future.
really thank you for finding this.
I had the same issue, here the problem was also me using a junction When starting from the actual path, it worked!