简体   繁体   English

找不到工作区文件('angular.json')

[英]workspace file ('angular.json') could not be found

I'm trying to run my angular application with ng serve but get this error: 我正在尝试使用ng serve运行我的角度应用程序,但出现此错误:

Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
    at WorkspaceLoader._getProjectWorkspaceFilePath (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\workspace-loader.js:38:19)
    at WorkspaceLoader.loadWorkspace (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\workspace-loader.js:25:21)
    at ServeCommand._loadWorkspaceAndArchitect (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:181:32)
    at ServeCommand.<anonymous> (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:48:25)
    at Generator.next (<anonymous>)
    at C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:3:12)
    at ServeCommand.initialize (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:47:16)
    at Object.<anonymous> (C:\Users\Roy\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js:83:23)

i followed the suggestions given on this question Error: Local workspace file ('angular.json') could not be found - without any luck. 我遵循了关于此问题的建议错误:找不到本地工作区文件('angular.json') -没有任何运气。

when i run ng -v on a global scope 当我在全局范围内运行ng -v时

 C:\Users\Roy>ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.1.0-beta.2
Node: 8.11.2
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.0-beta.2
@angular-devkit/core         0.7.0-beta.2
@angular-devkit/schematics   0.7.0-beta.2
@schematics/angular          0.7.0-beta.2
@schematics/update           0.7.0-beta.2
rxjs                         6.2.0
typescript                   2.7.2

when i run it in the project folder : 当我在项目文件夹中运行它时:

ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.1.0-beta.2
Node: 8.11.2
OS: win32 x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.0-beta.2 (cli-only)
@angular-devkit/core         0.7.0-beta.2 (cli-only)
@angular-devkit/schematics   0.7.0-beta.2 (cli-only)
@angular/cdk                 5.2.4
@angular/cli                 <error>
@angular/material            5.2.4
@schematics/angular          0.7.0-beta.2 (cli-only)
@schematics/update           0.7.0-beta.2 (cli-only)
rxjs                         5.5.7
typescript                   2.4.2

when running npm install on the project folder i get this error : 在项目文件夹上运行npm install时,出现以下错误:

npm install
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to http://172.23.4.20:4873/@angular%2fcli failed, reason: read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Roy\AppData\Roaming\npm-cache\_logs\2018-06-11T09_24_47_695Z-debug.log

I was facing this issue today. 我今天面对这个问题。 There were nothing wrong in my case, but just a silly mistake. 我的情况没有错,只是一个愚蠢的错误。 I was running my command ng serve and other angular cli commands outside of my app directory(which contains the node_modules . So, after move to that directory using cd m4moviesapp , and then run ng serve everything was working as expected. 我在我的应用程序目录(包含node_modules之外运行命令ng serve和其他angular cli命令,因此,在使用cd m4moviesapp移至该目录后,然后运行ng serve一切正常。

Directory 目录

在此处输入图片说明

Before 之前

在此处输入图片说明

After

在此处输入图片说明

我弄清楚了,我在git环境中工作,有人推了一个npmrc文件,其设置只允许从我们的内部服务器下载,这就是为什么每次我运行npm install都会出现错误,试图下载angular-cli。

This is because you have install angular in some directory and trying to use ng serve without creating your new project set-up 这是因为您已在某些目录中安装了angular并尝试使用ng serve而不创建新的项目设置
Generating and serving an Angular project via a development server ng new PROJECT-NAME cd PROJECT-NAME ng serve https://www.npmjs.com/package/@angular/cli#generating-and-serving-an-angular-project-via-a-development-server 通过开发服务器生成和服务Angular项目ng新的PROJECT-NAME cd PROJECT-NAME ng服务https://www.npmjs.com/package/@angular/cli#generating-and-serving-an-angular-project-通过-A-开发服务器

我运行了“ npm install”,我的项目获得了所有模块,并且运行了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到Angular 4本地工作区文件(&#39;angular.json&#39;) - Angular 4 Local workspace file ('angular.json') could not be found Angular 6:找不到本地工作区文件('angular.json') - Angular 6 : Local workspace file ('angular.json') could not be found 无法运行现有的 angular 项目 - 找不到本地工作区文件 (&#39;angular.json&#39;) - Not able to run exisitng angular project - Local workspace file ('angular.json') could not be found 错误:升级到 Angular 6 时找不到本地工作空间文件 ('angular.json') - Error: Local workspace file ('angular.json') could not be found when upgraded to Angular 6 找不到本地工作区文件(&#39;angular.json&#39;)。 但是相同的代码适用于另一台计算机 - Local workspace file ('angular.json') could not be found. But same code works in another computer 找不到Angular 5.2本地工作空间文件angular.json - Angular 5.2 Local workspace file angular.json not found 无法解析使用 Nativescript/ 错误文件 angular.json 迁移 Angular - Migrating Angular with Nativescript/ Error File angular.json could not be parsed 如何更换 angular.json 上的环境文件 - how to replace environment file on angular.json angular.json 文件中的根属性 - Root Property in angular.json file 无法加载架构 -- angular.json 文件 - Unable to load Schema -- angular.json file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM