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!
I am experiencing the same issue. I had my angular project working at one point but a few days ago something must have changed because I get the same error as santiagoblas when running ng serve
, even after creating a new app. Following are the results from running ng -v
:
Angular CLI: 1.7.3
Node: 8.9.4
OS: win32 x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
I have tried uninstalling and reinstalling Node.js.
Using Windows Command Prompt instead of Git Bash solved the issue, though I would like to know why Git Bash is no longer working for me.
Same issue here, I tried to create a new angular project with cli on a vanilla windows 10 computer. Installed everything from scratch with newest version and got this exact same error when executing ng build/serve with GIT Bash.
Thank's a lot @aruwanip for the advice to use windows CMD it works well that way !
I am getting the same error after upgrading to angular 5.2.10 from 4.4.3 and angular/cli to 1.7.4 from 1.6.7. I am running "ng build --watch --extractCss --base-href /portal/ --e=local --deploy-url=/Content/portal/" and I see the following...
ERROR in ./src/main.ts
Module build failed: Error: C:\dev\portal\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:\dev\portal\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23)
at plugin.done.then (C:\dev\portal\node_modules\@ngtools\webpack\src\loader.js:467:39)
at process._tickCallback (internal/process/next_tick.js:109:7)
ERROR in ./src/polyfills.ts
Module build failed: Error: C:\dev\portal\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:\dev\portal\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23)
at plugin.done.then (C:\dev\portal\node_modules\@ngtools\webpack\src\loader.js:467:39)
Having the same issue:
> yarn build
yarn run v1.6.0
$ ng build
Date: 2018-05-22T19:52:01.735Z
Hash: 7a9bf0b1a9416b4e7f92
Time: 5862ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 929 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 886 bytes [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 261 kB [initial] [rendered]
ERROR in ./src/main.ts
Module build failed: Error: /Users/keegomyneego/Documents/Projects/roshub_web_app/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 (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:662:23)
at plugin.done.then (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/loader.js:467:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
@ multi ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: Error: /Users/keegomyneego/Documents/Projects/roshub_web_app/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 (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:662:23)
at plugin.done.then (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/loader.js:467:39)
at <anonymous>
@ multi ./src/polyfills.ts
error Command failed with exit code 1.
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"baseUrl": "src",
"paths": {
"$assets/*": ["assets/*"],
"$environment": ["environments/environment"],
"$library/*": ["library/*"],
"~core/*": ["app/core/*"],
"~shared/*": ["app/shared/*"],
"~account/*": ["app/features/account/*"],
"~device/*": ["app/features/device/*"],
"~login/*": ["app/features/login/*"],
"~settings/*": ["app/features/settings/*"],
"~view/*": ["app/features/view/*"]
},
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015"
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"files": [
"./scripts/extend-rxjs.ts"
]
}
.angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "roshub_web_app"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "rh",
"styles": [
"sass/styles-app-loading.scss",
"sass/styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": [
"../node_modules"
]
},
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {
}
}
}
__Update__: Removing the "files"
key from tsconfig.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.
@keego That is correct; for additional details please see here: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
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
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.)
mklink
so tested it in DOS console through the link, and not through the link, and got the same result; symlinks are badSo 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 had the same issue, here the problem was also me using a junction
When starting from the actual path, it worked!
@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.
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 fought with this issue for 2 weeks. Turned out to be the symbolic link issue. Moving my project to a real directory and it solved the issue for me.
I thought this sym link thing doesn't apply to me since I never created one. Later on I realized that the path I am using is ~/My Documents.
The error went away when I used the path ~/Documents
Should have never put my code within documents!
dont use symlinks, I open dir in VSCode from symlink and got same error (path is with symlink not the real dir), when I open it in target dir (the parh was real) it works, doesnt need any changes
maybe hardlinks would be ok because it keeps true path
Not allowing Win symlinks in the path is really the answer, thanks! But I still fell that this could be worked somewhere... well, anyway, workaround ok!
@AlanCarlyle
Got this problem as well and got it working by moving to a shorter absolute path (rather than one relative to a symlink).
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.
Same issue with D:\dev\path\to\folder
For reference if someone want to reproduce, I were using: mklink /J D:\dev C:\dev
.
When using C:\dev\path\to\folder
, it works fine.
This is still happening with the newest version of CLI?
Yes, still still happens with the latest cli. I just tried it today, because I opened my project after two month and had forget about this problem.
Starting the ng commands (serve, build, etc.) from a absolute path works but if you are on a symlinked path, you will get an error.
Because almost exclusively windows users get this problem, I think that it could be related to the different treatment of symlinks between Linux and Windows. Both "mklink" on windows cmd and "winln" on gitbash do not do the exactly same as "ln" in linux. And windows also treat symlinks in a slightly different way then linux do. But that this could be the reason of this problem is just a theory, because I have not enough background knowledge to say if this theory is correct..
Editing angular.json to add following attribute under the node "projects/{yourprojectname}/architect/build/options" should help:
"preserveSymlinks": true
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:
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2019-02-28T13:13:36.820Z
Hash: ebdef6caace71813630d
Time: 14555ms
chunk {main} main.js, main.js.map (main) 127 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 258 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 745 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 8 MB [initial] [rendered]
WARNING in ./node_modules/@angular/core/fesm5/core.js 18349:15-36
Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/@angular/core/fesm5/core.js 18361:15-102
Critical dependency: the request of a dependency is an expression
i ï½¢wdmï½£: Compiled with warnings.
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?
Editing angular.json to add following attribute under the node "projects/{yourprojectname}/architect/build/options" should help:
"preserveSymlinks": true
You make my day guy, many thanks ! :)
Yep, 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
I faced the same problem during ng serve
but npm start
solved my problem as it was showing some error in webpack module
npm start
also did the job for me
I faced the same problem during
ng serve
butnpm start
solved my problem as it was showing some error in webpack module
Editing angular.json to add following attribute under the node "projects/{yourprojectname}/architect/build/options" should help:
"preserveSymlinks": trueYou make my day guy, many thanks ! :)
Editing angular.json to add following attribute under the node "projects/{yourprojectname}/architect/build/options" should help:
"preserveSymlinks": true
Thanks much.
I still have a feeling that something in node_modules is missing.
BTW:
Had this issue today, caused by being in the project folder through a symlink when running ng serve
.
Is there any reason to no have preserveSymlinks
as true
by default?
Check the path. I found out that my path had spaces such as:
'~/My Documents/'
That did not work for me.
Solution: I put the project somewhere else that had no spaces within the file path.
@jaythomasv29 Looks to me that the issue was the My Documents
symlink. You can confirm by putting the project back where it was and adding the preserveSymlinks
property to true
as suggested here in a comment above
Hello,
I also experienced this problem for a while, and I solved it by just changing the location of my project. I put it in the disk other than that of the system (example: d :, e: ...)
Having the same issue:
> yarn build yarn run v1.6.0 $ ng build Date: 2018-05-22T19:52:01.735Z Hash: 7a9bf0b1a9416b4e7f92 Time: 5862ms chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered] chunk {main} main.bundle.js, main.bundle.js.map (main) 929 bytes [initial] [rendered] chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 886 bytes [initial] [rendered] chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 261 kB [initial] [rendered] ERROR in ./src/main.ts Module build failed: Error: /Users/keegomyneego/Documents/Projects/roshub_web_app/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 (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:662:23) at plugin.done.then (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/loader.js:467:39) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) @ multi ./src/main.ts ERROR in ./src/polyfills.ts Module build failed: Error: /Users/keegomyneego/Documents/Projects/roshub_web_app/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 (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:662:23) at plugin.done.then (/Users/keegomyneego/Documents/Projects/roshub_web_app/node_modules/@ngtools/webpack/src/loader.js:467:39) at <anonymous> @ multi ./src/polyfills.ts error Command failed with exit code 1.
tsconfig.json
tsconfig.app.json
.angular-cli.jsonUpdate: 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.
Had this problem as well on Mac Mojave 10.14.16, removing "files" from tsconfig.app.json solved it
Thanks!
Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Please check out our submission guidelines to understand why we can't act on issues that are lacking important information.
If the problem persists, please file a new issue and ensure you provide all of the required information when filling out the issue template.
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._
Most helpful comment
Editing angular.json to add following attribute under the node "projects/{yourprojectname}/architect/build/options" should help:
"preserveSymlinks": true