【问题标题】:Angular 6 can't find .angular-cli.json and change the outDirAngular 6 找不到 .angular-cli.json 并更改 outDir
【发布时间】:2018-05-21 00:49:16
【问题描述】:

我遵循了一个在线教程,该教程说我必须在 .angular-cli.json 文件中设置 outDir。当我运行 ng build 时,这会将编译后的代码放在我的 app.js 文件夹中指定的正确目录中。问题是我在任何地方都找不到文件。教程link

解决方案已经完成并且没有错误,我现在要做的就是将 Angular 与我拥有的后端连接并在 localhost:3000 上运行它。到目前为止,我只在 tsconfig.json 文件中找到了 outdir。当我运行编译器时,文件最终位于默认的 dist 文件夹中。

【问题讨论】:

  • 在angular 6中,它的“angular.json”和输出路径是options entry下的“outputPath”

标签: angular config


【解决方案1】:

您所指的教程是使用 Angular 2,而 Angular 的最新版本是 6

从 Angular 6 开始的 CLI 项目将使用 angular.json 而不是 .angular-cli.json 进行构建和项目配置。

每个 CLI 工作区都有项目,每个项目都有目标,每个目标可以有配置。Docs
如果您希望生成的工件存储在自定义位置修改输出路径从"outputPath": "dist/ng6","outputPath": "dist/yourcustomlocation",build 目标

    {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ng6": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ng6",**<----/modify this**
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets":

更多教程使用HttpModule 已被弃用,您应该改用HttpClientModule

【讨论】:

    猜你喜欢
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 2018-04-15
    • 2017-07-01
    • 1970-01-01
    • 2018-09-16
    • 1970-01-01
    相关资源
    最近更新 更多