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
the generated file should be put in the default project. For now, you must specify the project name with --project projectName
Reacted by Zahid Mahmood, Youssef Ait Elhaj, Akshay Sarkar, Eran Medan, simon-an, Jay Lin, Abhishek Sharma, Sergey Lebedev, Michael Shtilerman, Mustafa Çağatay Tulun and 3 more
Reacted by Sergey Lebedev, Jesse Booth, Alex Patterson and kza_web
"projects"."myGreatApp-e2e"."root" changes from "" to "e2e" allowing the ng g module test command to build the module in the correct location. We don't use e2e so I don't know what else this breaks. Easy enough, as a workaround, to change and put back just before building an new module.
I'm not having any problem changing the root folder from src to client with CLI version 6.1 (installed globally) on Windows 10 x64. Here is what I did:
Problem: I was running the command ng generate component components/home (create the "home" component in the components directory) from the location of angular-project/src/.
Solution: Back out into the root of your angular project and specify the path you want the component to generate in like so:
ng generate component src/components/home
The above command should create a "home" component in the components/ directory inside the src/ directory.
Activity
WillsXiao commentedon May 5, 2018
I have met the same issue.
TedCorleone commentedon May 5, 2018
@nginx17 @WillsXiao , try to restart the terminal, issue caused by new thread.
WillsXiao commentedon May 5, 2018
@TedCorleone I've tried it. It didn't work
wdev1980 commentedon May 5, 2018
I have the same issue on OSX.
nginx17 commentedon May 5, 2018
@TedCorleone same as @WillsXiao didn't work
I tried to restart the terminal and restart my computer but it still didn't work
matheusdavidson commentedon May 6, 2018
same here on OSX, not only generates in the project root folder, but with all the path down to my project root folder.
My project:
/var/www/project/
When i generate, for example, home module:
/var/www/project/var/www/project/home/
matheusdavidson commentedon May 6, 2018
Just generated a new angular 6 project and tried to generate a module or a component and had the same issue, i`m using the latest version:
stewones commentedon May 6, 2018
Same here
sandangel commentedon May 6, 2018
the generated file should be put in the default project. For now, you must specify the project name with --project projectName
nginx17 commentedon May 6, 2018
@sandangel still doesn't work
sandangel commentedon May 6, 2018
@nginx17 notice that your project must be placed in the projectRoot folder configued in angular.json
nginx17 commentedon May 6, 2018
@sandangel i try
what i missed, angular.json default generated, not change
matheusdavidson commentedon May 6, 2018
@sandangel, still not working
It says there is no ngModule because its looking in the wrong place, what OS are you using?
matheusdavidson commentedon May 6, 2018
If i try to create a module for example, it looks like it creates in the right place:

but it doesn't:

nginx17 commentedon May 6, 2018
@matheusdavidson i think this is not about OS, you used OSX and i used Linux, but problem is same. i don't know how about windows
60 remaining items
grimace commentedon Jun 25, 2018
That didn't work for me, hence more digging and now works without moving projects in angular.json.
dkteam commentedon Jun 26, 2018
Fix here, everyone.
https://github.com/rafasantos/matchandtrade-web-ui/commit/a5e6b6085157285900c6a3cfdc5e0ceccda3a9fa
ivyblossom commentedon Jun 26, 2018
Thanks @dkteam 👏
It worked for me 🎉
ZdebK commentedon Jun 27, 2018
For me worked that I changed the path. I was in src folder.
cd ../fixed this :D
PawelOwczarekFalcon commentedon Jul 3, 2018
@grimace works fine :)
agroupp commentedon Jul 9, 2018
@grimace was very helpful, thanks
chrisBosse commentedon Jul 17, 2018
Very much like @grimace 's workaround above.
For me, I was able to leave the project order the same in
angular.jsonand only change the e2e project's"root"path.{ "projects": { "myGreatApp": { "root": "" }, "myGreatApp-e2e": { "root": "e2e" } } }"projects"."myGreatApp-e2e"."root"changes from""to"e2e"allowing theng g module testcommand to build the module in the correct location. We don't use e2e so I don't know what else this breaks. Easy enough, as a workaround, to change and put back just before building an new module.Angular 6.0.6
Angular CLI 6.0.8
angular-devkit/schematics 0.6.8
jgswiss commentedon Jul 25, 2018
Deleting the "e2e" in angular.json under:
"app-e2e": {
"root": "",
"sourceRoot": "e2e",
"projectType": "application"
to
"app-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
fixed my problem!
Eternal21 commentedon Jul 27, 2018
Same problem on Windows, after upgrading to the latest cli (6.1.1). The solution that worked for me was suggested by @srkt
"yourappname-app" and "yourappname-app-e2e"
gremo commentedon Jul 28, 2018
I'm not having any problem changing the root folder from
srctoclientwith CLI version 6.1 (installed globally) on Windows 10 x64. Here is what I did:Save the patch file
root-change.diff:Apply the patch file and install vendor:
All the following commands works:
ng serve --open ng build --prod ng test ng e2eComponent generation will correctly generate the component in the new root folder:
zachgoll commentedon Sep 15, 2018
My fix was fairly simple:
Problem: I was running the command
ng generate component components/home(create the "home" component in the components directory) from the location ofangular-project/src/.Solution: Back out into the root of your angular project and specify the path you want the component to generate in like so:
The above command should create a "home" component in the
components/directory inside thesrc/directory.Hope that helps!
angular-automatic-lock-bot commentedon Sep 8, 2019
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.