首页 > 解决方案 > Docker 的 Angular 图像因依赖错误而退出

问题描述

我的 docker 映像具有的节点版本 = v10.15.3 NPM 版本 = 6.4.1

下面是我的package.json,它是应用程序所有依赖项的列表。

{
},
  "dependencies": {
    "@akveo/ng2-completer": "^9.0.1",
    "@angular/animations": "^10.0.10",
    "@angular/cdk": "10.1.1",
    "@angular/common": "^10.0.10",
    "@angular/compiler": "^10.0.10",
    "@angular/core": "^10.0.10",
    "@angular/forms": "^10.0.10",
    "@angular/google-maps": "^10.1.3",
    "@angular/material": "^11.1.1",
    "@angular/platform-browser": "^10.0.10",
    "@angular/platform-browser-dynamic": "^10.0.10",
    "@angular/router": "^10.0.10",
    "@asymmetrik/ngx-leaflet": "3.0.1",
    "@nebular/auth": "6.0.0",
    "@nebular/eva-icons": "6.0.0",
    "@nebular/security": "6.0.0",
    "@nebular/theme": "6.0.0",
    "@swimlane/ngx-charts": "^14.0.0",
    "angular2-chartjs": "0.4.1",
    "bootstrap": "4.3.1",
    "chart.js": "2.7.1",
    "ckeditor": "4.7.3",
    "classlist.js": "1.1.20150312",
    "core-js": "2.5.1",
    "csv-parser": "^3.0.0",
    "echarts": "^4.0.2",
    "eva-icons": "^1.1.3",
    "intl": "1.2.5",
    "ionicons": "2.0.1",
    "leaflet": "1.2.0",
    "nebular-icons": "1.1.0",
    "ng2-ckeditor": "^1.2.9",
    "ng2-smart-table": "^1.6.0",
    "ngx-echarts": "^4.2.2",
    "node-sass": "^4.12.0",
    "normalize.css": "6.0.0",
    "pace-js": "1.0.2",
    "roboto-fontface": "0.8.0",
    "rxjs": "6.6.2",
    "rxjs-compat": "6.3.0",
    "socicon": "3.0.5",
    "style-loader": "^1.1.3",
    "tinymce": "4.5.7",
    "tslib": "^2.0.0",
    "typeface-exo": "0.0.22",
    "web-animations-js": "^2.3.2",
    "xlsx": "^0.16.9",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.6",
    "@angular/cli": "^10.0.6",
    "@angular/compiler-cli": "^10.0.10",
    "@angular/language-service": "10.0.10",
    "@compodoc/compodoc": "1.0.1",
    "@fortawesome/fontawesome-free": "^5.2.0",
    "@types/d3-color": "1.0.5",
    "@types/googlemaps": "^3.39.3",
    "@types/jasmine": "2.5.54",
    "@types/jasminewd2": "2.0.3",
    "@types/leaflet": "1.2.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "conventional-changelog-cli": "1.3.4",
    "husky": "0.13.3",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "npm-run-all": "4.0.2",
    "protractor": "~7.0.0",
    "rimraf": "2.6.1",
    "stylelint": "7.13.0",
    "ts-node": "3.2.2",
    "tslint": "~6.1.0",
    "tslint-language-service": "^0.9.9",
    "typescript": "3.9.7"
  }
}

下面是我使用的Dockerfile 。

Dockerfile

FROM node:10.15.3-alpine AS node
WORKDIR /application
COPY . .
RUN npm install
RUN npm run build --prod
#Stage 2
FROM nginx:1.17.1-alpine
COPY --from=node /application/dist/application /usr/share/nginx/html

当它到达命令时:RUN npm run build --prod编译一段时间后,它会抛出这个错误:

#13 262.8 ERROR in The target entry-point "ng2-smart-table" has missing dependencies:       
#13 262.8  - ng2-completer
#13 262.8
#13 262.9 npm ERR! code ELIFECYCLE
#13 262.9 npm ERR! errno 1
#13 262.9 npm ERR! ngx-admin@6.0.0 build: `ng build`
#13 262.9 npm ERR! Exit status 1
#13 262.9 npm ERR!
#13 262.9 npm ERR! Failed at the ngx-admin@6.0.0 build script.
#13 262.9 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
#13 263.9
#13 263.9 npm ERR! A complete log of this run can be found in:
#13 263.9 npm ERR!     /root/.npm/_logs/2021-04-10T13_17_44_149Z-debug.log
------
executor failed running [/bin/sh -c npm run build --prod]: exit code: 1
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command docker build --pull --rm -f "Dockerfile" -t diacareportal1:v1 "."" terminated with exit code: 1.

我需要做什么才能让它工作?

标签: node.jsangulardockernpm

解决方案


推荐阅读