serve命令需要在Angular项目中运行,但是在对Angular 7应用进行docker化时找不到项目定义

时间:2019-07-17 14:46:47

标签: docker npm docker-compose dockerfile angular7

当我使用stefanscherer / node-windows(在Windows模式下运行docker)对有角度的应用程序进行docker化时,会收到以下警告消息

frontend_1        | The serve command requires to be run in an Angular project, but a project definition could not be found.
frontend_1        | npm info lifecycle frontend@0.0.0~start: Failed to exec start script
frontend_1        | npm ERR! code ELIFECYCLE
frontend_1        | npm ERR! errno 1
frontend_1        | npm ERR! frontend@0.0.0 start: `ng serve "build"`
frontend_1        | npm ERR! Exit status 1
frontend_1        | npm ERR!
frontend_1        | npm ERR! Failed at the frontend@0.0.0 start script.
frontend_1        | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
frontend_1        | npm timing npm Completed in 17774ms

下面是我的Angular 7的docker文件

 FROM stefanscherer/node-windows:latest
 RUN mkdir usr/src/app
 WORKDIR /usr/src/app
 COPY frontend/package.json /usr/src/app
 RUN npm install
 RUN npm install -g @angular/cli@7.3.5
 COPY . /usr/src/app
 EXPOSE 4200
 CMD npm start build

Angular应用的docker-compose文件部分如下

image: frontend
build:
   context: .
   dockerfile: frontend\Dockerfile

ports:
    - "4200:4200"

请帮助我解决此问题。

还要提供我的package.json和有角度的版本

  "dependencies": {
    "@angular/animations": "^7.2.8",
    "@angular/cdk": "^7.3.3",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/flex-layout": "^7.0.0-beta.23",
    "@angular/forms": "~7.2.0",
    "@angular/material": "^7.3.3",
    "@angular/platform-browser": "^7.2.8",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "bootstrap": "^3.4.1",
    "core-js": "^2.5.4",
    "jquery": "^3.3.1",
    "ngx-bootstrap": "^3.2.0",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.5",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
  

节点:10.15.2

     

Angular版本Angular CLI:8.1.0

     

操作系统:win32 x64

@angular-devkit/architect:    0.801.0
@angular-devkit/core    :     8.1.0
@angular-devkit/schematics  : 8.1.0
@schematics/angular   :       8.1.0
@schematics/update     :      0.801.0
rxjs                 :        6.4.0

0 个答案:

没有答案