Repository navigation
Closed
Labels
P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfularea: @angular/clifreq3: highseverity5: regression
Milestone
Description
Versions
➜ ng -v
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.7
Node: 10.3.0
OS: linux x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, elements
... forms, http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.6.7
@angular-devkit/build-angular 0.6.7
@angular-devkit/build-ng-packagr 0.6.7
@angular-devkit/build-optimizer 0.6.7
@angular-devkit/core 0.6.7
@angular-devkit/schematics 0.6.7
@angular/cdk 6.2.1
@angular/cli 6.0.7
@angular/flex-layout 6.0.0-beta.15
@angular/material 6.2.1
@angular/pwa 0.7.0-beta.1
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.0.7
@schematics/angular 0.6.7
@schematics/update 0.6.7
ng-packagr 3.0.1
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3Repro steps
ng new test-proj
ng g application test-app
// edit angular.json defaultProject -> test-app
ng g c test-comp
CREATE src/app/test-comp/test-comp.component.css (0 bytes)
CREATE src/app/test-comp/test-comp.component.html (28 bytes)
CREATE src/app/test-comp/test-comp.component.spec.ts (643 bytes)
CREATE src/app/test-comp/test-comp.component.ts (280 bytes)
UPDATE src/app/app.module.ts (406 bytes)Observed behavior
<!-- Normally this includes a stack trace and some more information. -->
ref: #10352 , #10327
cli always generate schematics (pwa,component...) to the project under src/ folder
Desired behavior
please consider using the defaultProject for single project command like ng generate, ng add... I'm still experiencing the generated files go into the project under src/ folder instead of the project under projects/defaultProject/src/
Mention any other details that might be useful (optional)
I also see an regression that the generated component nolonger be added to the nearest NgModule, but always be added to the app.module.ts. Should I create another issue for that?
Reacted by Radoslav Kirilov, Eran Medan and Jean-Louis GUENEGO
Metadata
Metadata
Assignees
Labels
P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfularea: @angular/clifreq3: highseverity5: regression
Activity
rfuhrer commentedon Jun 11, 2018
A few of us are seeing this error after the fix for the CLI ignoring sourceRoot: #10653 (comment)
Thanks to @darinclark for finding a workaround. It appears to just grab the last project in your angular.json. So if you have a main project and then a e2e project, reorder them so the main project is last and your default generate commands will go to the main project instead of e2e. If you need to generate something to the e2e project then you can use the
--path e2eoverridetiagomsmagalhaes commentedon Jun 12, 2018
just pinging to say that I faced the issue with the same angular and angular-cli versions as @rfuhrer and @darinclark workaround works.
Just curious to know if the error may be in the generation of angular.json or on the cli itself
smoke commentedon Jun 21, 2018
This problem seems to happen only when an angular app is updated using
ng update.There are a bit different configurations generated with
ng new projectandng updatesee the listed files below.The noticeable difference that I see and could cause this problem is that:
"projects.client-e2e.sourceRoot" = "e2e"and"projects.client-e2e.root" = """projects.client-e2e.sourceRoot" = undefinedand"projects.client-e2e.root" = "e2e/"Here are the complete files for reference:
and
CarstenLeue commentedon Jun 21, 2018
This might have a similar root cause as #11321
Brocco commentedon Aug 3, 2018
The reason they are created to the project you were not expecting, is because they are being run in the directory of the initial project. The logic to determine the project:
In this case (and the default case) the root of the initial project is
""so when you run a generate command from the root directory of your workspace it finds that project.alexeagle commentedon Sep 27, 2018
What we'd like to do is:
defaultProjectkey inangular.jsonin 7.0defaultProjectkey in 8.0cdto the directory where the project is they want to act on, or use command line options likeng serve my-project1alexeagle commentedon Mar 7, 2019
We have decided to standardize on the model where the default application goes in the root of the workspace, next to the
angular.jsonfile.The reason is that we want to reduce the concepts needed to get started with Angular, so we don't want to explain "workspace" and "project" to new users. There is only "ng new" and you get an "application".
For novice/intermediate users, we suggest that users simply run "ng new" again to get a separate application in a separate workspace.
The "monorepo" use case, where you want multiple applications/libraries to live together in one workspace, will continue to be supported for advanced users. Note that the workflow
ng new --createApplication=false; cd new_wksp; ng generate applicationlets you create a workspace where all projects are under theprojectsdirectory with no app in the root.angular-automatic-lock-bot commentedon Sep 9, 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.