Local workspace file ('angular.json') could not be found. But same code works in another computer
Solution 1
it’s probably because your global @angular/ cli, project @angular/cli version or @angular/compiler-cli doesn’t match.
Debugging this
first of all run
ng -v
to check the global version of your angular, then compare the version with your angular project versions. if it matches with them or no.
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
Solution 2
Also, make sure you're in the folder where the angular.json file is located. That's what my issue turned out to be. Doh! I was in the parent folder in the cmd window and it didn't like that. Changing directory to the project folder fixed the issue for me. Sort of an "is it plugged in" solution, but thought I'd share it anyway.
Related videos on Youtube
SmartestVEGA
Updated on September 15, 2022Comments
-
SmartestVEGA over 1 year
I am getting following error in one computer, but it works in another computer for the same source code
Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found
Not working computer
Working computer
I tried following commands mentioned in this stackoverflow link, but no luck
ng update @angular/cli --migrate-only --from=1.7.4 This removed .angular-cli.json and created angular.json.
If this leads to your project using 1.7.4, install v6 locally:
npm install --save-dev @angular/[email protected]
Not working computer ng version
PS D:\Work\Source> ng -v Your global Angular CLI version (6.0.8) is greater than your local version (6.0.0-rc.4). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
_ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _
| | | | |/ _
| '| | | | | | | / \| | | | (| | || | | (| | | | || | | | // __| ||__, |__,||__,|| ____|_____|| |/Angular CLI: 6.0.0-rc.4 Node: 8.11.3 OS: win32 x64 Angular: 5.2.10 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router Package Version ------------------------------------------------------ @angular-devkit/architect 0.5.6 @angular-devkit/core 0.5.6 (cli-only) @angular-devkit/schematics 0.5.6 (cli-only) @angular/cli 6.0.0-rc.4 @ngtools/json-schema 1.2.0 @schematics/angular 0.5.6 (cli-only) @schematics/update 0.5.6 rxjs 5.5.10 typescript 2.5.3
Working computer ng -version
PS V:\Jaison\Incomming\HISUI_Grid\HISUI\HISUI_04July2018\HISUI\src> ng -v Your global Angular CLI version (6.0.8) is greater than your local version (1.7.4). The local Angular CLI version is used. To disable this warning use "ng config -g cli.warnings.versionMismatch false". _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/ Angular CLI: 1.7.4 Node: 8.9.3 OS: win32 x64 Angular: 5.2.10 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router @angular/cli: 1.7.4 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.3.2 @angular-devkit/schematics: 0.3.2 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.2 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.5.3 webpack: 3.11.0
-
Hrishikesh Kale over 5 yearsI hope you are running ng serve in the directory where your Angular project is
-
Hrishikesh Kale over 5 yearsyes, I did have an answer for you please check if that works!
-
-
SmartestVEGA over 5 yearsi have updated the question , please check ... what command i need to run
-
SmartestVEGA over 5 yearsso as per the comment above , the angular CLI working version is 1.7.4 and non working version is 6.0.0-rc.4.. So i need to downgrate to 1.7.4???
-
Hrishikesh Kale over 5 yearsno, you need to update angular CLI of your local system, by using npm install -g @angular/cli@latest