我在一台电脑上遇到以下错误,但它在另一台电脑上运行相同的源代码
Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found
电脑不工作
工作电脑
我尝试执行此 stackoverflow link 中提到的命令, 但没有运气
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/cli@v6.0.0-rc.4
无法正常工作的计算机 ng 版本
PS D:\Work\Source> ng -v 您的全局 Angular CLI 版本 (6.0.8) 高于本地版本 版本 (6.0.0-rc.4)。使用本地 Angular CLI 版本。
要禁用此警告,请使用“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
工作电脑 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
最佳答案
可能是你的全局@angular/cli、项目@angular/cli版本或者@angular/compiler-cli不匹配。
调试这个
first of all run
ng -v
检查你的 Angular 全局版本,然后将版本与你的 Angular 项目版本进行比较。如果它与他们匹配或不匹配。
如果不匹配,请更新或降级。例如降级项目@angular/cli run
npm uninstall -D @angular/cli
npm install -D @angular/cli@5.2.0
升级全局运行@angular/cli run
npm install -g @angular/cli@latest
关于angular - 找不到本地工作区文件 ('angular.json')。但是相同的代码在另一台计算机上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51493222/