F11
F11

Reputation: 3806

Not able to run exisitng angular project - Local workspace file ('angular.json') could not be found

I am not able to run an existing project and getting an error "Local workspace file ('angular.json') could not be found." my package.config having these values(not a complete file)

{
  "name": "xx",
  "version": "1.0.0",
  "private": true,
  "description": ".",
  "scripts": {
    "start": "webpack-dev-server --inline --progress --port 8888",
    "test": "karma start karma.webpack.conf.js",
    "build": "rimraf dist && webpack --config config/webpack.prod.js --bail",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "^4.1.2",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",

  },
  "devDependencies": {
    "@angular/cli": "^6.2.4",
 }

and when I run outside project folder this is what I got

ng version

"Angular CLI: 6.2.4
Node: 12.16.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.8.4
@angular-devkit/core         0.8.4
@angular-devkit/schematics   0.8.4
@schematics/angular          0.8.4
@schematics/update           0.8.4
rxjs                         6.2.2
typescript                   2.9.2"

and when I run inside src project folder this is what I got

ng version

Angular CLI: 6.2.4
Node: 12.16.0
OS: win32 x64
Angular:
...

------------------------------------------------------
@angular-devkit/architect    <error>
@angular-devkit/core         <error>
@angular-devkit/schematics   <error>
@schematics/angular          <error>
@schematics/update           <error>
rxjs                         6.2.2

Upvotes: 0

Views: 1620

Answers (1)

Kiran Mistry
Kiran Mistry

Reputation: 2725

If you run into this issue, it’s probably because your global @angular/cli , project @angular/cli version or @angular/compiler-cli doesn’t match.

First of all run

ng -v

to check the global version (i.e it outputs 5.2.0) and then look into your project package.json, if it match with the project versions.

"@angular/cli": "6.0.0-rc.3",
"@angular/compiler-cli": "^5.2.0",

Fix it

If something doesn’t match, update or downgrade it. For example to downgrade project @angular/cli run

npm uninstall -D @angular/cli
npm install -D @angular/[email protected]

To upgrade global run @angular/cli run

npm install -g @angular/cli@latest

Note

It is necessary to have both a global and local install for the tools to work.

In global mode (-g or –global appended to the command), it uninstalls/installs the package as a global package. To uninstall/install the project package use -D or –save-dev and package will be removed/added to your devDependencies.

The @ after package name specifies the desired version.


Second Option

And For Me i solved the problem by following the following steps

  1. npm uninstall -g @angular/cli
  2. npm cache verify
  3. npm install -g @angular/cli --no-optional
  4. ng new new-project
  5. ng s / ng s -o

Third Option

If you run the command 'ng new my-app' when you are already in the app folder it opens yet another folder with the same name inside. Check whether you run the command 'ng serve' in the first or second folder.

Example:

If you run 'ng serve' in: C:\Users\hoehmann\my-app

you need to run it in: C:\Users\hoehmann\my-app\my-app

Upvotes: 1

Related Questions