【问题标题】:Ng build The ..\src\environments\environment.dev.ts path in file replacements does not existng build 文件替换中的..\src\environments\environment.dev.ts 路径不存在
【发布时间】:2019-10-13 01:57:23
【问题描述】:

我正在尝试做ng build --configuration=development,但它给出了以下错误:

C:\Users\Marina\Desktop\heliosFrontEnd_admin\src\environments\environment.dev.ts 文件替换中的路径不存在。错误: C:\Users\Marina\Desktop\heliosFrontEnd_admin\src\environments\environment.dev.ts 文件替换中的路径不存在。 在 Object.normalizeFileReplacements (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules@angular-devkit\build-angular\src\utils\normalize-file-replacements.js:25:19) 在 Object.normalizeBuilderSchema (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules@angular-devkit\build-angular\src\utils\normalize-builder-schema.js:37:97) 在 BrowserBuilder.run (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules@angular-devkit\build-angular\src\browser\index.js:31:33) 在 MergeMapSubscriber.getBuilderDescription.pipe.operators_1.concatMap.builder [作为项目] (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules@angular\cli\node_modules@angular-devkit\architect\src\architect.js:121:415) 在 MergeMapSubscriber._tryNext (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\operators\mergeMap.js:69:27) 在 MergeMapSubscriber._next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\operators\mergeMap.js:59:18) 在 MergeMapSubscriber.Subscriber.next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\Subscriber.js:67:18) 在 MapSubscriber._next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\operators\map.js:55:26) 在 MapSubscriber.Subscriber.next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\Subscriber.js:67:18) 在 TapSubscriber._next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\operators\tap.js:65:26) 在 TapSubscriber.Subscriber.next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\Subscriber.js:67:18) 在 MergeMapSubscriber.notifyNext (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\operators\mergeMap.js:92:26) 在 InnerSubscriber._next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\InnerSubscriber.js:28:21) 在 InnerSubscriber.Subscriber.next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\Subscriber.js:67:18) 在 MapSubscriber._next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\operators\map.js:55:26) 在 MapSubscriber.Subscriber.next (C:\Users\Marina\Desktop\heliosFrontEnd_admin\node_modules\rxjs\internal\Subscriber.js:67:18)

在我的angular.json 文件中,我有

"build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico",
              "src/config"
            ],
            "styles": [
              "node_modules/perfect-scrollbar/css/perfect-scrollbar.css",
              "src/assets/scss/material-dashboard.scss",
              "src/assets/css/demo.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.js",
              "node_modules/popper.js/dist/umd/popper.js",
              "node_modules/bootstrap-material-design/dist/js/bootstrap-material-design.min.js",
              "node_modules/arrive/src/arrive.js",
              "node_modules/moment/moment.js",
              "node_modules/perfect-scrollbar/dist/perfect-scrollbar.min.js",
              "node_modules/bootstrap-notify/bootstrap-notify.js",
              "node_modules/chartist/dist/chartist.js"
            ]
          },
          "configurations": {
            "development": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.dev.ts"
                }
              ]
            },

我检查了路径,它是正确的,文件在那里。怎么了?

【问题讨论】:

  • 你有一个名为environment.dev.ts的文件吗?
  • 是的,我有这个文件,它在我指定的路径中
  • 通常开发不需要提及环境参数,你是不是特别想这样做?所以ng build 会为你构建dev,不需要有一个名为env...dev.ts的文件
  • 能否确认是否可以打开这条路径C:\Users\Marina\Desktop\heliosFrontEnd_admin\src\environments\environment.dev.ts

标签: angular angular7 ng-build


【解决方案1】:

在“配置”之后,您必须看到“服务”。

添加开发。

 "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "{your_project_name}:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "{your_project_name}:build:production"
            },
            "development": {
              "browserTarget": "{your_project_name}:build:development"
            }
          }
        },

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多