首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >转向角应用程序:不存在文件替换中的/app/src/environments/environments.prod.ts路径

转向角应用程序:不存在文件替换中的/app/src/environments/environments.prod.ts路径
EN

Stack Overflow用户
提问于 2021-10-19 14:02:44
回答 1查看 177关注 0票数 0

我在试着修改一个有角度的应用程序。下面是dockerfile:

代码语言:javascript
复制
FROM node:alpine AS build
ENV NODE_ENV=development

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY *.json ./
COPY *.js ./
COPY src .

RUN npm run build

FROM nginx:alpine

WORKDIR /usr/share/nginx/html

COPY --from=build /app/dist .

下面是angular.json配置:

代码语言:javascript
复制
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "cli": {
    "analytics": false
  },
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "web": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        },
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "web:build:production"
            },
            "development": {
              "browserTarget": "web:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "web:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        }
      }
    }
  },
  "defaultProject": "web"
}

它在第9步抛出以下错误的原因是什么?我试图在互联网上查找这个错误,并找到了一对资源(),但这些对我没有任何帮助。

代码语言:javascript
复制
Warning: Support was requested for IE 11 in the project's browserslist configuration. IE 11 support is deprecated since Angular v12.
For more information, see https://angular.io/guide/browser-support
An unhandled exception occurred: The /app/src/environments/environment.prod.ts path in file replacements does not exist.
See "/tmp/ng-PPmHPI/angular-errors.log" for further details.
unable to stream build output: The command '/bin/sh -c npm run build' returned a non-zero code: 127. Please fix the Dockerfile and try again..

这个错误似乎是不言自明的,但请注意,我在指定的路径中有该文件。所以这个错误肯定是由于别的原因造成的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-19 14:22:51

所以我需要反映完全相同的数据结构。而不是

代码语言:javascript
复制
COPY src .

一定是

代码语言:javascript
复制
COPY src ./src

感谢@jrichardsz告诉我一些调试步骤。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69632304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档