Angular-cli: [email protected] fails to create new project and serve it

Created on 3 Apr 2018  Â·  12Comments  Â·  Source: angular/angular-cli

Versions

Angular CLI: 6.0.0-rc.0
Node: 9.10.1
OS: darwin x64
Angular: 6.0.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 6.0.0-rc.0
@angular-devkit/architect: 0.0.10
@angular-devkit/build-angular: 0.0.10
@angular-devkit/build-optimizer: 0.4.9
@angular-devkit/core: 0.4.9
@angular-devkit/schematics: 0.5.0
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 6.0.0-beta.9
@schematics/angular: 0.5.0
@schematics/update: 0.5.0
typescript: 2.7.2
webpack: 4.1.0

Repro steps

When I ran "ng new ..." I already got a warning:

ng new -S --style=scss frontend
(node:96293) UnhandledPromiseRejectionWarning: Error: An old project has been detected, which needs to be updated to Angular CLI 6.

Please run the following commands to update this project.

  ng update @angular/cli --migrate-only --from=1.7.1
  npm i
    at WorkspaceLoader._assertUpdatedWorkspace (/usr/local/lib/node_modules/@angular/cli/models/workspace-loader.js:73:19)
    at WorkspaceLoader._getProjectWorkspaceFilePath (/usr/local/lib/node_modules/@angular/cli/models/workspace-loader.js:29:14)
    at WorkspaceLoader.loadWorkspace (/usr/local/lib/node_modules/@angular/cli/models/workspace-loader.js:25:21)
    at NewCommand._loadWorkspace (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:255:29)
    at NewCommand.<anonymous> (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:53:18)
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:3:12)
    at NewCommand.initialize (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:52:16)
(node:96293) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
...
...
added 1285 packages in 75.174s
    Directory is already under version control. Skipping initialization of git.
CREATE frontend/README.md (1034 bytes)
...

and ng serve fails on similar error:

npm start

> [email protected] start /Users/konradcerny/Sites/Erento/frontend
> ng serve

An old project has been detected, which needs to be updated to Angular CLI 6.

Please run the following commands to update this project.

  ng update @angular/cli --migrate-only --from=1.7.1
  npm i
Error: An old project has been detected, which needs to be updated to Angular CLI 6.

Please run the following commands to update this project.

  ng update @angular/cli --migrate-only --from=1.7.1
...

I didn't have this problem with version 6.0.0-beta.8

Most helpful comment

I run into the same issue upgrading to v. 6

All 12 comments

the change appears already in 6.0.0-beta.9

Heya @rokerkony, I think what's happening is that you have a .angular-cli.json file in one of the folders above your project and we incorrectly detect the current project to have not been migrated. This is something we will fix.

@filipesilva I just tried to verify your statement... but I got even more "interesting" output:
(created folder in root - [email protected])

➜  / sudo mkdir __temp
➜  / cd __temp
➜  /__temp ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 6.0.0-rc.0
Node: 9.10.1
OS: darwin x64
Angular:
...
➜  /__temp ng new -S --style=scss frontend

(node:99304) UnhandledPromiseRejectionWarning: Error: Local workspace file ('angular.json') could not be found.

but maybe it is related to what you wrote because it cannot find angular.json file

yes, I ran into this too.

Angular CLI: 6.0.0-rc.0
Node: 8.11.1
OS: darwin x64
Angular: 6.0.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 6.0.0-rc.0
@angular-devkit/architect: 0.0.10
@angular-devkit/build-angular: 0.0.10
@angular-devkit/build-optimizer: 0.4.9
@angular-devkit/core: 0.4.9
@angular-devkit/schematics: 0.5.0
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 6.0.0-beta.9
@schematics/angular: 0.5.0
@schematics/update: 0.5.0
typescript: 2.7.2
webpack: 4.1.0

I run into the same issue upgrading to v. 6

I am stuck at the same place.
I have the latest angular-cli version (6.0.3) on my system, and have undertaken a older project to make some changes in it. This project has cli(1.2.6-> as per package.json) and when I run the command ng --serve, it throws the error : Local workspace file ('angular.json') could not be found.

Any Advice on what all I will need to do to make this project run on my system?

@pratul1 The command ng update @angular/cli will delete the angular.cli.json and create an angular.json file for you.

Just be sure to make a backup of the original file first :)

How can I fix this when I did not backup the original angular.cli.json file... This is really confusing for beginners

I upgraded the angular CLI using below command

npm install @angular/cli@latest

angular_issue

then i got below error when run the command = ng update @angular/cli

Collection "@schematics/angular/migrations/migration-collection.json" cannot be
resolved.

My angular-cli.json is not getting upgraded to angular.json

For people googling this error. It’s probably because your global @angular/cli version and @angular/compiler-cli are differentf here is how to fix it (my blog).

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