Skip to content

Cannot create components with CLI on Windows #7960

Closed
@Feeni

Description

@Feeni

We are not able to generate components on a project that's using a slightly different directory structure. After a bit of testing, it seems like it's a Windows path issue as generating components on Macbooks are working just fine.

Bug Report or Feature Request (mark with an x)

- [ x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.5
node: 6.11.3
os: win32 x64
@angular/animations: 4.4.4
@angular/common: 4.4.4
@angular/compiler: 4.4.4
@angular/core: 4.4.4
@angular/forms: 4.4.4
@angular/http: 4.4.4
@angular/platform-browser: 4.4.4
@angular/platform-browser-dynamic: 4.4.4
@angular/router: 4.4.4
@angular/cli: 1.4.5
@angular/compiler-cli: 4.4.4
@angular/language-s
Windows 10 Enterprise version 1703

Repro steps.

  1. Create a new project using ng new PROJECT-NAME
  2. Create an apps folder inside of the src folder.
  3. Move everything in src/app into src/apps, which will result in a file structure of src/apps/app/<component>
  4. Change the apps root in .angular-cli.json to be src/apps

The final result of executing steps 1 to 4 can be seen here: https://github.com/Feeni/angular-cli-windows

  1. Attempt to generate a new component using ng g c test-me -d - an error will appear stating Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.
  2. Attempt to generate a new component using ng g c test-me --skip-import -d - it will do a dry run of the component creation, but the path will be src/apps/src/apps/<component>. Notice how the root seems to be duplicated twice.

The log given by the failure.

ng g c test-me -d
Error: Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.
Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.
ng g c test-me --skip-import -d
  create src/apps/src/apps/app/test-me/test-me.component.html (26 bytes)
  create src/apps/src/apps/app/test-me/test-me.component.spec.ts (629 bytes)
  create src/apps/src/apps/app/test-me/test-me.component.ts (272 bytes)
  create src/apps/src/apps/app/test-me/test-me.component.css (0 bytes)

NOTE: Run with "dry run" no changes were made.

NOTE: While there are no errors above, note how the path of src/apps is being copied twice.

Desired functionality.

We would like to use the Angular CLI to generate components even with a different directory structure on Windows.

Mention any other details that might be useful.

  • Our current work-around is to downgrade to v.1.3.2, as generating components in Windows works fine in that version.
  • When attempting to generate components using the repo linked above on a Macbook as well as using Bash on Ubuntu for Windows, it works with no issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: investigationRequires some digging to determine if action is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions