Angular-cli: Workspace needs to be loaded before it is used

Created on 30 May 2019  路  9Comments  路  Source: angular/angular-cli

馃悶 Bug report

Command (mark with an x)


- [x] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [x] add
- [x] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Angular CLI only works in my environment until 1.X version.

Description

When try to do any action that not needed be inside of Angular project, even without any argument (like: ng new or ng update), the console throws the message: _Workspace needs to be loaded before it is used_. This means that I can't create any project or use any tool of Angular 馃槩.

馃敩 Minimal Reproduction

First, install the angular cli (I only can install 7.X or a minor version, below explain that):
$ sudo npm i -g @angular/[email protected]

When the installation finish, I run this command for create a new project:
$ ng new any-project

And the console, output this message: Workspace needs to be loaded before it is used

馃敟 Exception or Error


Workspace needs to be loaded before it is used.
Error: Workspace needs to be loaded before it is used.
    at Workspace._assertLoaded (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/workspace/workspace.js:69:19)
    at Workspace._getTool (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/workspace/workspace.js:175:14)
    at Workspace.getCli (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/workspace/workspace.js:157:21)
    at Object.getConfiguredPackageManager (/usr/local/lib/node_modules/@angular/cli/utilities/config.js:131:32)
    at Object.getPackageManager (/usr/local/lib/node_modules/@angular/cli/utilities/package-manager.js:32:35)
    at new AddCommand (/usr/local/lib/node_modules/@angular/cli/commands/add-impl.js:24:49)
    at Object.runCommand (/usr/local/lib/node_modules/@angular/cli/models/command-runner.js:146:25)
    at async default_1 (/usr/local/lib/node_modules/@angular/cli/lib/cli/index.js:27:31)

馃實 Your Environment


Angular CLI: 7.3.9
Node: 12.3.1
OS: linux x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.9
@angular-devkit/core         7.3.9
@angular-devkit/schematics   7.3.9
@schematics/angular          7.3.9
@schematics/update           0.13.9
rxjs                         6.3.3
typescript                   3.2.4

Anything else relevant?

I created other issue, related because can't install the latest version of cli (8.x). This si the issue number: #14584

angulacli low regression bufix

Most helpful comment

I had the same problem. In my case the file .angular-config.json in my home directory existed and was just empty. After deleting the file it works fine.

All 9 comments

I understand that it is a issue of angular core, because I not found any information about this message (only when I search in the source code). I am in the right way?

Heya @amoncusir, you are in the right repository, yes. We'll look at it, and thank you for opening an issue.

Do you maybe have an angular.json file in the parent directory of the folder you are in when you do ng new?

I don't. I run new command in many directories and none has any file named angular.json.

Hey! I finded a fast solution for solve this problem. I one of my attempts to know what happens, I see that if create a new user in the same os environment, the problem nothing happens.

My solution is remove all user data related with npm and angular cli, like .angular-config.json user file, .npm folder, .cache folder and others (I don't remember all files that I removed :cry:)

That is possible it angular save any state or any others files in user folder? Or that it npm save any state or other think?

Thank's!

Heya @amoncusir, I'm glad your issue got sorted. Angular CLI keeps some configuration in angular.json and .angular-config.json files. I know of some cases in the past where users ended up with double npm global installs that made it hard for things to work so maybe that was related. Either way it's good that you are unblocked :D

I had the same problem. In my case the file .angular-config.json in my home directory existed and was just empty. After deleting the file it works fine.

I had the same problem. In my case the file .angular-config.json in my home directory existed and was just empty. After deleting the file it works fine.

This issue was driving me crazy for the last two weeks. Couldn't use the ng command, couldn't update the ng client.. anything. This helped, thanks!

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

delasteve picture delasteve  路  3Comments

5amfung picture 5amfung  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments