Skip to content

Angular cli Generates Wrong Directory Path in app.module.ts #7135

Closed
@djtahl

Description

@djtahl

Bug Report or Feature Request (mark with an x)

  • bug report
  • feature request

Versions.

node -v : v6.10.0
npm -v : 5.3.0
ng -v :

@angular/cli: 1.2.4
node: 6.10.0
os: darwin x64

Repro steps.

  • install the latest angular-cli (version : 1.2.4)
  • go in the desired repository
  • run the command ng new myProject
  • go in the created project
  • go in myProject/src/app and create a folder "common"
  • go in "common" folder
  • run ng g c myComponent

The log given by the failure.

  • the component is created at the right location :
installing component
  create src/app/common/my-component/my-component.component.css
  create src/app/common/my-component/my-component.component.html
  create src/app/common/my-component/my-component.component.spec.ts
  create src/app/common/my-component/my-component.component.ts
  update src/app/app.module.ts
  • but the path written in "app.module.ts" is wrong
ERROR in /Users/u.name/myProject/src/app/app.module.ts (5,38): Cannot find module './common/src/app/common/my-component/my-component.component'.

ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve './common/src/app/common/my-component/my-component.component' in '/Users/u.name/myPoject/src/app'
 @ ./src/app/app.module.ts 10:0-99
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

Desired functionality.

The path written is constantly adding "src/app" part whereas older version of the cli did not have this behavior
The correct import statement should be :
import { MyComponentComponent } from './common/my-component/my-component.component';

Mention any other details that might be useful.

This issue has also been reported on StackOverflow by another user :
https://stackoverflow.com/questions/45293787/angular-cli-generates-wrong-directory-path-in-app-module-ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulneeds: investigationRequires some digging to determine if action is neededseverity5: regressiontype: bug/fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions