angular-cli: Angular cli Generates Wrong Directory Path in app.module.ts

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 26
  • Comments: 23 (8 by maintainers)

Commits related to this issue

Most upvoted comments

1.3.0 still same…

I use 1.6.3 and ng new project-name still results:

Error: Path “/app/app.module.ts” does not exist. Path “/app/app.module.ts” does not exist.

This issue was fixed in 1.4.0, but not 1.3. We are looking at fixing it in 1.3 as well.

+1