GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Ng generate always assumes an `app` folder · Issue #9370 · angular/angular-cli

Ng generate always assumes an app folder #9370

New issue
Copy link
New issue
Copy link
Open
Enhancement
Open
Ng generate always assumes an app folder#9370
Enhancement
Copy link
Labels
area: @schematics/angularfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authorsLabel to add when the not a sufficient number of votes or comments from unique authorsworkaround1: obvious
Milestone
needsTriage

Description

@mikehallishere
mikehallishere
opened on Jan 24, 2018
Issue body actions

Our project setup doesn't have an immediate sub-folder of app, however, it appears that running ng generate always assume that you have an app folder under the app root folder you specified in .angular-cli.json

Versions

Angular CLI: 1.6.0
Node: 7.0.0
OS: darwin x64
Angular:
...

Repro steps

  • Setup a simple .angular-cli.json with:
{
  "apps": [
    {
      "name": "client",
      "root": "projects/client"
    }
  ]
}
  • Run:
ng g c form-inputs/mike --skip-import --dry-run --app=client

Observed behavior

You'll see the output path always assumes an app folder:

  create projects/client/app/form-inputs/mike/mike.component.css (0 bytes)
  create projects/client/app/form-inputs/mike/mike.component.html (23 bytes)
  create projects/client/app/form-inputs/mike/mike.component.spec.ts (614 bytes)
  create projects/client/app/form-inputs/mike/mike.component.ts (261 bytes)

Desired behavior

I'd like an option to be able to configure whether your project has the app folder or not. Or maybe an option to configure the whole path the component gets created in.

Reacted by ekumpe, Michael McDonald, Ben Elliott, Eduard Kolosovskyi, John Crim, Ruffin, Nguyen Tran Tan An, Lars Berger, Denis Bendrikov and Martin Sikora

Activity

Next
  1. mikehallishere
    changed the title [-]Ng generate assumes an `app` folder[/-] [+]Ng generate always assumes an `app` folder[/+] on Jan 24, 2018
  2. filipesilva
    added
    comp: cli/generate
    on Jan 25, 2018
  3. PoiScript commented on Feb 1, 2018

    @PoiScript
    PoiScript
    on Feb 1, 2018
    More actions

    Actually, there is an undocumented option in .angular-cli.json called appRoot which is probably you're looking for.

    Reacted by Martin Sikora, Bruno Mayer Paixão, codeepic, Ryan Pivovar and Miquel Canal
  4. hansl
    added
    type: RFC / discussion / question
    on Feb 1, 2018
  5. martinsik commented on Feb 13, 2018

    @martinsik
    martinsik
    on Feb 13, 2018
    More actions

    @PoiScript is right, there's appRoot options for this, see #7775.

  6. filipesilva
    added
    area: @schematics/angular
    and removed
    comp: cli/generate
    on Jun 8, 2018
  7. leonadler commented on Jun 19, 2018

    @leonadler
    leonadler
    on Jun 19, 2018
    More actions

    Using appRoot leads to an error "Workspace needs to be loaded before it is used."
    and is not included in the json-schema for angular.json.

    Reacted by jacobjojan
  8. PoiScript commented on Jun 19, 2018

    @PoiScript
    PoiScript
    on Jun 19, 2018
    More actions

    @leonadler appRoot is used for angular cli 1.x project. angular cli 6 introduces a new configuration schema. Each projects now has individual root and sourceRoot options, see https://github.com/angular/angular-cli/wiki/angular-workspace

  9. jacobjojan commented on Jul 10, 2018

    @jacobjojan
    jacobjojan
    on Jul 10, 2018
    More actions

    ng generate is adding app to the path by default. How to remove 'app' ?
    "root": "",
    "sourceRoot": "ui-lib/src",
    "projectType": "library",

    ng g module dashboard/widget -d
    CREATE src/app/dashboard/widget/widget.module.spec.ts (275 bytes)
    CREATE src/app/dashboard/widget/widget.module.ts (190 bytes)

    Reacted by Leon Adler, Wasif Ali, Bruno Mayer Paixão, Colby Rome, Michael McDonald, Umut Akkaya, Ruffin, Gary Alfred, Ryan Knittel and Nathaniel A Collier
  10. wasif-digitalnet commented on Aug 1, 2018

    @wasif-digitalnet
    wasif-digitalnet
    on Aug 1, 2018
    More actions

    I'm having the same issue as @jacobjojan, every time I run ng generate it generates by default in app folder, I want to generate out of app folder, how to do that?

  11. giolf commented on Aug 22, 2018

    @giolf
    giolf
    on Aug 22, 2018
    More actions

    @wasif-digitalnet what about

    ng generate module ../my-module

    CREATE src/my-module/my-module.module.spec.ts (292 bytes)
    CREATE src/my-module/my-module.module.ts (192 bytes)
    
    Reacted by Wasif Ali, Elio Maggini, Deepak Pathak, Colby Rome, Michael McDonald, apijay20, Thomas Cayne, Chetan Baadkar, Elio Maggini, sajidnovateus and 7 more
    Reacted by Ruffin
  12. wasif-digitalnet commented on Aug 28, 2018

    @wasif-digitalnet
    wasif-digitalnet
    on Aug 28, 2018
    More actions

    @giolf I have tried it, I guess there was some issues while generating the project, I made a new project and it's working fine now,

  13. giolf commented on Aug 28, 2018

    @giolf
    giolf
    on Aug 28, 2018
    More actions

    @wasif-digitalnet probably you run that command in a nested folder of your project ?

    Anyway I’m glad to hear that you could solve it

  14. ilivestrong commented on Oct 8, 2018

    @ilivestrong
    ilivestrong
    on Oct 8, 2018
    More actions

    @giolf Your solution worked... Cheers!

  15. 1 remaining item

  16. ngbot
    added this to the needsTriage milestone on Jan 24, 2019
  17. Paitum commented on Jul 31, 2019

    @Paitum
    Paitum
    on Jul 31, 2019
    More actions

    This problem is still unresolved.

    We have a code-base similar to Angular Material, where the library modules folders are directly beneath the main library folder.

    We have recently replaced our custom build systems in favor of the Angular CLI, but when using the ng generate commands, they automatically add either app or lib depending on the project type (application or library).

    Why can't this be configurable? Why isn't "sourceRoot" the literal root?

    Reacted by Umut Akkaya, John Crim, Terry Brown, Noorsil Karedia, Ruffin, Gary Alfred, Lars Berger, Nguyen Tran Tan An, mossiomylv, Nathaniel A Collier and 1 more
  18. filipesilva
    added
    featureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issues
    and removed
    type: RFC / discussion / question
    on Oct 8, 2019
  19. ngbot
    modified the milestones: needsTriage, Backlog on Oct 8, 2019
  20. alan-agius4
    added
    workaround1: obvious
    on Jan 8, 2021
  21. angular-robot
    added
    feature: votes requiredFeature request which is currently still in the voting phaseFeature request which is currently still in the voting phase
    on Feb 1, 2022
  22. angular-robot commented on Feb 1, 2022

    @angular-robot
    angular-robotBot
    on Feb 1, 2022
    Contributor
    More actions

    Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

    Find more details about Angular's feature request process in our documentation.

  23. ngbot
    modified the milestones: Backlog, needsTriage on Feb 1, 2022
  24. angular-robot
    removed
    feature: votes requiredFeature request which is currently still in the voting phaseFeature request which is currently still in the voting phase
    on Feb 21, 2022
  25. angular-robot commented on Feb 21, 2022

    @angular-robot
    angular-robotBot
    on Feb 21, 2022
    Contributor
    More actions

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  26. angular-robot
    added
    feature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authorsLabel to add when the not a sufficient number of votes or comments from unique authors
    on Feb 21, 2022
  27. umagon commented on Aug 6, 2025

    @umagon
    umagon
    on Aug 6, 2025
    More actions

    This style guide https://angular.dev/style-guide#organize-your-project-by-feature-areas recommends using /src as the root to put feature folders inside.

    This conflicts with Angular CLI schematics path adding app between src and the name of the component.

    Reacted by Gavin Campbell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @schematics/angularfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: insufficient votesLabel to add when the not a sufficient number of votes or comments from unique authorsLabel to add when the not a sufficient number of votes or comments from unique authorsworkaround1: obvious

    Type

    Enhancement

    Projects

    No projects

      Milestone

      • needsTriageNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.