Angular-cli: ng generate using wrong root directory on upgraded Angular application (5 -> 6)

Created on 3 Jul 2018  路  2Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Area

- [ ] devkit
- [ ] schematics

(Unsure at this time which area it affects.)

Versions

Node: 8.11.3
npm: 6.1.0
Angular CLI (global): 6.0.8

Repro steps

When ng update @angular/cli is run on an Angular 5 project, the angular.json file that gets generated has an improper setting in the e2e section of the configuration that interferes with the behavior of ng generate.

    "test-ng5-app-e2e": {
      "root": "",
      "sourceRoot": "e2e",
      ...
    }

Steps:

  • Create a new Angular 5 project (I used these steps: https://stackoverflow.com/a/50467119/6189080)
  • Install the latest CLI version on the project (npm install @angular/[email protected])
  • Run ng update @angular/cli on the project
  • From the source folder of the project, run:

    • ng generate service test --dry-run

    • ng generate component test --dry-run

The log given by the failure

$ ng g s test --dry-run
CREATE e2e/app/test.service.spec.ts (362 bytes)
CREATE e2e/app/test.service.ts (133 bytes)

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

$ ng g c test --dry-run
Could not find an NgModule. Use the skip-import option to skip importing in NgModule.

Desired functionality

ng generate works correctly out of the box on an upgraded application.

The simplest version would be to have the default settings match the initial settings for a newly-generated Angular 6 project.

    "test-ng6-app-e2e": {
      "root": "e2e/",
      ...
    }

Mention any other details that might be useful

I first ran across the fix in this StackOverflow comment. I have reproduced this fix in my own project, and ng generate is now working as expected.

Most helpful comment

This is actually fixed in master and will be included in 6.1. However, thank you for the detailed issue reported.

All 2 comments

This is actually fixed in master and will be included in 6.1. However, thank you for the detailed issue reported.

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanStureNielsen picture JanStureNielsen  路  3Comments

hareeshav picture hareeshav  路  3Comments

delasteve picture delasteve  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

hartjo picture hartjo  路  3Comments