Skip to content

(Docs) renaming a project manually leaves it unusable #39909

@moniuch

Description

@moniuch

Bug Report or Feature Request (mark with an x)

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

Area

- [x] devkit (not sure, judging by the log output)
- [ ] schematics

Versions

Angular CLI: 6.0.8
Node: 8.11.2
OS: win32 x64
Angular: 6.0.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.8.3

Repro steps

After I created an angular/cli project by issuing ng new ng6 (which obviously created a directory named so, and initialized git that way) I started to play around with it and came to idea to make it a real app.

As a result, I decided to rename it to a more significant name, say ng6catalogue, so I:

  • replaced all occurrences of ng6 in the project
  • renamed git origin
  • renamed directory

Restarted IDE, reopened the renamed directory, and tried to ng serve, when I got this error:

The log given by the failure

Project 'ng6' could not be found in workspace.
Error: Project 'ng6' could not be found in workspace.
    at Workspace.getProject (D:\Dev\ng6school\node_modules\@angular-devkit\core\src\workspace\workspace.js:83:19)
    at Architect.getBuilderConfiguration (D:\Dev\ng6school\node_modules\@angular-devkit\architect\src\architect.js:96:41)
    at DevServerBuilder._getBrowserOptions (D:\Dev\ng6school\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:309:41)
    at MergeMapSubscriber.check_port_1.checkPort.pipe.operators_1.concatMap [as project] (D:\Dev\ng6school\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:34:153)
    at MergeMapSubscriber._tryNext (D:\Dev\ng6school\node_modules\rxjs\internal\operators\mergeMap.js:65:27)
    at MergeMapSubscriber._next (D:\Dev\ng6school\node_modules\rxjs\internal\operators\mergeMap.js:55:18)
    at MergeMapSubscriber.Subscriber.next (D:\Dev\ng6school\node_modules\rxjs\internal\Subscriber.js:64:18)
    at TapSubscriber._next (D:\Dev\ng6school\node_modules\rxjs\internal\operators\tap.js:62:26)
    at TapSubscriber.Subscriber.next (D:\Dev\ng6school\node_modules\rxjs\internal\Subscriber.js:64:18)
    at portfinder.getPort (D:\Dev\ng6school\node_modules\@angular-devkit\build-angular\src\angular-cli-files\utilities\check-port.js:26:21)
    at D:\Dev\ng6school\node_modules\portfinder\lib\portfinder.js:160:14
    at D:\Dev\ng6school\node_modules\async\lib\async.js:52:16
    at D:\Dev\ng6school\node_modules\async\lib\async.js:269:32
    at D:\Dev\ng6school\node_modules\async\lib\async.js:44:16
    at D:\Dev\ng6school\node_modules\portfinder\lib\portfinder.js:122:16
    at Server.onListen (D:\Dev\ng6school\node_modules\portfinder\lib\portfinder.js:45:7)

Tried to ng eject but this command had been temporarily disabled. So now the project is unusable.

There is a fix: to revert all the occurrences of the new project name in angular.json, back to the old one. This though:

Desired functionality

Desired functionality would be to have ng rename command to handle rename scenario safely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureLabel used to distinguish feature request from other issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions