错误:找不到本地工作区文件(“ angular.JSON ”)

我将travis-ci与我的GitHub帐户(https://github.com/pradeep0601/angular5-router-app)集成在一起。

当我将@angular/cli版本从1.7.4更新到6.0.0-RC.3时,构建开始失败,并出现错误:

Local workspace file ('angular.json') could not be found.
Error: Local workspace file ('angular.json') could not be found.
at WorkspaceLoader._getProjectWorkspaceFilePath (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:37:19)
at WorkspaceLoader.loadWorkspace (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/workspace-loader.js:24:21)
at TestCommand._loadWorkspaceAndArchitect (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:177:32)
at TestCommand.<anonymous> (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:45:25)
at Generator.next (<anonymous>)
at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:3:12)
at TestCommand.initialize (/home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/architect-command.js:44:16)
at /home/travis/build/pradeep0601/Angular5-Router-App/node_modules/@angular/cli/models/command-runner.js:100:23

为了更好地了解运行环境,请使用package.JSON代码片段:

    "@angular/cli": "6.0.0-rc.3",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
283195 次浏览

我刚刚遇到了同样的问题。

它与V6.0.0-RC.2版本相关,https://github.com/angular/angular-cli/releases

新的配置格式。新文件可以在angular.JSON中找到(但也可以接受.angular.JSON)。在CLI1.7项目上运行NG Update将使您进入新配置。

我需要执行:

ng update @angular/cli --migrate-only --from=1.7.4

这消除了.angular-cli.json并产生了angular.json

如果这导致您的项目使用1.7.4,请在本地安装V6:

npm install --save-dev @angular/cli@v6.0.0-rc.4

并再次尝试将项目更新为:

ng update @angular/cli --migrate-only --from=1.7.4

卸载旧版本的Angular CLI,并安装Angular CLI Global:

将Angular CLI全局包更新到下一个版本“@angular/compiler-CLI ”:“^6.0.0 ”

npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli@next

通过运行以下命令生成新项目和默认应用程序:

ng new my-project
cd my-project
ng serve

与最近的版本,没有--migrate-only,我得到了回购更新。

我做了__ABC 0

Angular CLI配置格式已更改,您的现有配置可通过运行以下命令自动更新:

ng update @angular/cli
Updating karma configuration
Updating configuration
Removing old config file (.angular-cli.json)
Writing config file (angular.json)
Some configuration options have been changed, please make sure to update any npm scripts which you may have modified.
DELETE .angular-cli.json
CREATE angular.json (3684 bytes)
UPDATE karma.conf.js (1040 bytes)
UPDATE src/tsconfig.spec.json (322 bytes)
UPDATE package.json (1340 bytes)
UPDATE tslint.json (3140 bytes)

我收到了相同的错误消息。对我来说这是一个愚蠢的错误,我没有在我的Angular项目所在的目录中运行ng serve。在运行此命令之前,请确保您位于正确的目录(项目目录)中。

如果各种更新突击队不会这样做。尝试删除package-lock.JSON。然后运行NPM安装。在经历了大量的更新突击队后,我成功了。

检查您正在执行命令的文件夹结构,您应该运行命令“ ng serve ”,其中结构中应该有一个angular.JSON文件。

当我们运行命令时,默认情况下将生成angular.JSON文件

npm安装-G '@angular/CLI ' NG新项目_名称 然后CD项目_文件夹 然后,运行NG SERVE.对我来说

很有效。

如果您不知道当前项目的版本,则可以省略--from命令并键入--migrate-only

NG Update@Angular/CLI--仅迁移

尝试使用以下命令:

ng update @angular/cli --migrate-only --from=1.7.4

它将执行以下

  • 正在更新Karma配置

  • 正在更新配置

  • 删除旧的配置文件(.angular-CLI.JSON)

  • 编写配置文件(angular.JSON)

请注意,上面的命令应该在你有文件的文件夹中运行。angular-cli.json,然后它将被angular.json替换。

查看此链接以从Angular 5.2迁移到6。 https://update.angular.io/

升级到8.9版本对我来说很有效。 enter image description here

这对我很有用:

删除文件夹node_modules

运行命令:npm install

(如果第一次不起作用,重复2到3次,这很有趣,但对我来说很有效。

好的,当我更新我的angular cli版本时,我遇到了同样的问题。

之前我使用的是1.7.4,现在我将其升级为angular cli 6.0.8

要更新角度CLI全局:

npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli@latest

要更新角度CLI设备:

npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

要在NPM安装后修复审核问题,请执行以下操作:

npm audit fix

修复与“ angular.JSON ”相关的问题:

ng update @angular/cli --migrate-only --from=1.7.4

对我来说,问题是我在Rails项目文件夹中有一个Angular项目文件夹,我在Rails父文件夹而不是实际的Angular文件夹中运行所有的Angular更新命令。

我在Docker容器中看到了这个错误消息。我解决了这个问题,并补充道:

WORKDIR /usr/src

到dockerfile.

只需在控制台中运行ng update @angular/cli。 在运行该命令后,您可能会发现一些漏洞(如果使用NPM),但只需在控制台中__abc3__abc0即可修复这些漏洞。此命令将扫描项目中的任何漏洞,还将通过安装这些依赖项的更新来修复兼容性问题。如果您不希望立即自动修复这些漏洞,可以在控制台中通过跑步npm audit fix --dry-run -json来执行试运行:。这将使您了解命令__abc0将在控制台中以JSON的形式执行的操作。

对我来说,这个问题是因为全球@角度/CLI版本和@angular/compiler-CLI是不同的。查看package.JSON

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

如果它们不匹配,则更新或降级其中一个。

我也遇到了同样的问题,我所做的对我有用的是:

  1. package.JSON文件中,将Angular CLI版本更新为我想要的版本:

    "devDependencies": { ...
    "@angular/cli": "^6.0.8",
    ...
    }
    
  2. Delete the node_modules folder, in order to clean the project before update the dependencies with:

    npm install
    
    
    ng update @angular/cli
    
  3. Try to build again my project (the last and successful attempt)

    ng build --prod
    

我也遇到了同样的问题,我只是执行了下面的命令。

NG更新@Angular/CLI--仅迁移--从=1.6.4

它只是删除angular-cli.json并创建angular.json。你可以在日志中找到这个。

一旦你开始执行。您将能够在您的终端中看到以下日志。

        Updating karma configuration
Updating configuration
Removing old config file (.angular-cli.json)
Writing config file (angular.json)
Some configuration options have been changed, please make sure to update any
npm scripts which you may have modified.
DELETE .angular-cli.json
CREATE angular.json (3599 bytes)
UPDATE karma.conf.js (962 bytes)
UPDATE src/tsconfig.spec.json (324 bytes)
UPDATE package.json (1405 bytes)
UPDATE tsconfig.json (407 bytes)
UPDATE tslint.json (3026 bytes)

对我来说,起作用的是创建一个新的 Angular项目,并将Angular.JSON文件复制到项目中,该项目由于Angular.JSON文件缺失而出现问题。

我遇到了同样的问题,发现我的项目中没有package.JSON(只有package-lock.JSON)。那我

  1. 已从源代码管理中恢复package.JSON
  2. 已卸载Global和Local Angular-CLI版本(如说明所述)
  3. 遵循标准升级程序

..一切都很顺利。花了一段时间才弄明白,但这对我来说很重要。

~/Desktop $ ng serve

找不到本地工作区文件(“ angular.JSON ”)。

错误:找不到本地工作区文件(“ angular.JSON ”)。

at WorkspaceLoader._getProjectWorkspaceFilePath (/usr/lib/node_modules/@angular/cli/models/workspace-loader.js:37:19)
at WorkspaceLoader.loadWorkspace (/usr/lib/node_modules/@angular/cli/models/workspace-loader.js:24:21)
at ServeCommand._loadWorkspaceAndArchitect (/usr/lib/node_modules/@angular/cli/models/architect-command.js:180:32)
at ServeCommand.<anonymous> (/usr/lib/node_modules/@angular/cli/models/architect-command.js:47:25)
at Generator.next (<anonymous>)
at /usr/lib/node_modules/@angular/cli/models/architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (/usr/lib/node_modules/@angular/cli/models/architect-command.js:3:12)
at ServeCommand.initialize (/usr/lib/node_modules/@angular/cli/models/architect-command.js:46:16)
at Object.<anonymous> (/usr/lib/node_modules/@angular/cli/models/command-runner.js:87:23)

这是因为我没有选择角度项目目录。

应该是这样的:

~/Desktop/AngularProject$NG服务

我试图将我的爱奥尼亚4应用程序设置为PWA运行。当我运行命令时:

ng add @angular/pwa

...收到错误消息。经过一些尝试和错误,我发现当我的项目被创建时,启动命令是错误的。我使用的是Ionic 3版本:

ionic start myApp tabs --type=ionic-angular

正确的是:

ionic start myApp tabs --type=angular

类型中没有“ ionic-”。这解决了错误。

只需检查您的目录,您必须在创建项目的同一目录上运行“ ng serve ”。

因此,首先输入您的项目目录。

对于那些已经克隆了一个项目并试图运行它的人来说,你需要先运行npm install。我完全忘记了运行它,只是在安装节点模块之前运行了ng serve