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

时间:2018-06-11 09:30:24

标签: angular npm angular-cli npm-install angular-cli-v6

我尝试使用select * from my_keyspace.foo_table ct join rdd on ct.bar = rdd.bar where ct.baz < rdd.baz 运行我的角度应用程序但是出现此错误:

ng serve

我遵循了关于这个问题的建议Error: Local workspace file ('angular.json') could not be found - 没有任何运气。

当我在全局范围内运行-v时

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)

当我在项目文件夹中运行它时:

 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

在项目文件夹上运行npm install时出现此错误:

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

4 个答案:

答案 0 :(得分:4)

我今天面对这个问题。我的情况没有错,只是一个愚蠢的错误。我在我的应用程序目录(包含ng serve的目录之外运行命令angular cli和其他node_modules命令,因此,在使用cd m4moviesapp移至该目录之后,然后运行ng serve一切正常。

目录

enter image description here

之前

enter image description here

之后

enter image description here

答案 1 :(得分:0)

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

答案 2 :(得分:-1)

这是因为您已在某些目录中安装了angular并尝试使用ng serve而不创建新的项目设置
  通过开发服务器生成和服务Angular项目 ng新的项目名称 cd项目名称 ng服务 https://www.npmjs.com/package/@angular/cli#generating-and-serving-an-angular-project-via-a-development-server

答案 3 :(得分:-1)

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