Angular2在Docker中找不到module:'./class'

我正在为使用Gitlab和Docker的angular2应用程序构build自动部署平台。 该项目基于https://akveo.github.io/ng2-admin/

我对模板项目做了一些修改,即添加一些我自己的服务和模型。 在我的app目录中,我添加了一个servicsmodels目录。

服务/ example.service.ts:

 import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import { Example } from '../models/Example'; @Injectable() export class ExampleService { private BaseUrl = 'http://localhost:6969/api/1.0/example' constructor(private http: Http) {} Example(Payload: string) { //do stuff } } 

车型/ example.ts

 export class Example{ ID: number; //etc } 

Docker Image:节点

脚本:

 npm install npm run build:prod:aot 

的package.json:

 { "name": "App", "version": "1.0.0", "description": "Angular and Bootstrap 4 Admin Template.", "author": "Akveo <contact@akveo.com>", "homepage": "http://akveo.github.io/App/", "repository": { "type": "git", "url": "https://github.com/akveo/App.git" }, "bugs": { "url": "https://github.com/akveo/App/issues" }, "license": "MIT", "scripts": { "ng": "ng", "rimraf": "rimraf", "changelog": "standard-changelog", "start": "ng serve", "start:hmr": "ng serve --hmr", "start:aot": "ng serve --aot", "start:prod": "ng serve --prod", "start:prod:aot": "ng serve --prod --aot", "build": "npm run clean:dist && ng build", "build:prod": "npm run build -- --prod", "build:prod:aot": "npm run build:prod -- --aot", "build:ci": "npm run build:prod && npm run build:prod:aot", "build:demo": "npm run build:prod:aot -- --base-href \"http://akveo.com/App/\"", "test": "ng test -sr", "test:coverage": "npm run clean:coverage && ng test -sr -cc", "lint": "ng lint", "lint:styles": "stylelint ./src/app/**/*.scss", "lint:ci": "npm run lint && npm run lint:styles", "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "ng e2e", "clean:dist": "npm run rimraf -- dist", "clean:coverage": "npm run rimraf -- coverage", "docs:deploy": "wintersmith build -C docs && gh-pages -d docs/build", "docs:serve": "wintersmith preview -C docs" }, "private": true, "dependencies": { "@angular/animations": "4.1.3", "@angular/common": "4.1.3", "@angular/compiler": "4.1.3", "@angular/core": "4.1.3", "@angular/forms": "4.1.3", "@angular/http": "4.1.3", "@angular/platform-browser": "4.1.3", "@angular/platform-browser-dynamic": "4.1.3", "@angular/platform-server": "4.1.3", "@angular/router": "4.1.3", "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.26", "@ngx-translate/core": "6.0.1", "@ngx-translate/http-loader": "0.0.3", "amcharts3": "github:amcharts/amcharts3", "ammap3": "github:amcharts/ammap3", "angular2-datatable": "0.6.0", "animate.css": "3.5.2", "bootstrap": "4.0.0-alpha.6", "chart.js": "1.1.1", "chartist": "0.10.1", "chroma-js": "1.3.3", "ckeditor": "4.6.2", "core-js": "2.4.1", "easy-pie-chart": "2.1.7", "font-awesome": "4.7.0", "fullcalendar": "3.3.1", "google-maps": "3.2.1", "ionicons": "2.0.1", "jquery": "3.2.1", "jquery-slimscroll": "1.3.8", "leaflet": "0.7.7", "leaflet-map": "0.2.1", "lodash": "4.17.4", "ng2-ckeditor": "1.1.6", "ng2-completer": "1.3.1", "ng2-handsontable": "0.48.0", "ng2-slim-loading-bar": "4.0.0", "ng2-smart-table": "1.0.3", "ng2-tree": "2.0.0-alpha.5", "ngx-uploader": "2.2.5", "normalize.css": "6.0.0", "roboto-fontface": "0.7.0", "rxjs": "5.4.0", "zone.js": "0.8.11" }, "devDependencies": { "@angular/cli": "1.0.4", "@angular/compiler-cli": "4.1.3", "@types/fullcalendar": "2.7.40", "@types/jasmine": "2.5.38", "@types/jquery": "2.0.41", "@types/jquery.slimscroll": "1.3.30", "@types/lodash": "4.14.61", "@types/node": "6.0.69", "codelyzer": "3.0.1", "gh-pages": "0.12.0", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "3.2.0", "karma": "1.4.1", "karma-chrome-launcher": "2.0.0", "karma-cli": "1.0.1", "karma-coverage-istanbul-reporter": "0.2.0", "karma-jasmine": "1.1.0", "karma-jasmine-html-reporter": "0.2.2", "npm-run-all": "4.0.2", "protractor": "5.1.0", "rimraf": "2.6.1", "standard-changelog": "1.0.1", "stylelint": "7.10.1", "ts-node": "2.1.2", "tslint": "5.2.0", "tslint-eslint-rules": "4.0.0", "tslint-language-service": "0.9.6", "typescript": "2.3.2", "typogr": "0.6.6", "underscore": "1.8.3", "wintersmith": "2.2.5", "wintersmith-sassy": "1.1.0" } } 

我的脚本在Windows上成功运行,但在节点泊坞窗容器中运行时失败。

错误:

 ERROR in /builds/mibzman/App/web/src/app/services/request.service.ts (4,27): Cannot find module '/../models/Example'. ERROR in /builds/mibzman/App/web/src/app/models/survey.ts (1,27): Cannot find module './Example'. ERROR in /builds/mibzman/App/web/src/app/models/survey.ts (2,34): Cannot find module './OtherModel'. ERROR in /builds/mibzman/App/web/src/app/models/survey.ts (3,32): Cannot find module './SomeOtherModel'. ERROR in /builds/mibzman/App/web/src/app/models/surveyresponse.ts (1,24): Cannot find module './Answer'. ERROR in /builds/mibzman/App/web/src/app/pages/new/new.component.ts (5,27): Cannot find module '../../models/Example'. ERROR in /builds/mibzman/App/web/src/app/pages/new/new.service.ts (11,27): Cannot find module '../../models/Example'. ERROR in /builds/mibzman/App/web/src/app/pages/new/components/ExampleForm/ExampleForm.component.ts (3,27): Cannot find module '../../../../models/Example'. ERROR in ./src/app/pages/new/components/ExampleForm/ExampleForm.component.ts Module not found: Error: Can't resolve '../../../../models/Example' in '/builds/mibzman/App/web/src/app/pages/new/components/ExampleForm' @ ./src/app/pages/new/components/ExampleForm/ExampleForm.component.ts 2:0-57 @ ./src/$$_gendir/app/pages/new/new.component.ngfactory.ts @ ./src/$$_gendir/app/pages/new/new.module.ngfactory.ts @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/app/app.component.ts @ ./src/$$_gendir/app/app.component.ngfactory.ts @ ./src/$$_gendir/app/app.module.ngfactory.ts @ ./src/main.ts @ multi ./src/main.ts npm info lifecycle App@1.0.0~build: Failed to exec build script npm ERR! Linux 4.4.0-78-generic npm ERR! argv "/usr/local/bin/node" "/builds/mibzman/App/web/node_modules/.bin/npm" "run" "build" "--" "--prod" "--aot" npm ERR! node v7.10.0 npm ERR! npm v3.5.4 npm ERR! code ELIFECYCLE npm ERR! App@1.0.0 build: `npm run clean:dist && ng build "--prod" "--aot"` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the App@1.0.0 build script 'npm run clean:dist && ng build "--prod" "--aot"'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the App package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! npm run clean:dist && ng build "--prod" "--aot" npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs App npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls App npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /builds/mibzman/App/web/npm-debug.log npm info lifecycle App@1.0.0~build:prod: Failed to exec build:prod script npm ERR! Linux 4.4.0-78-generic npm ERR! argv "/usr/local/bin/node" "/builds/mibzman/App/web/node_modules/.bin/npm" "run" "build:prod" "--" "--aot" npm ERR! node v7.10.0 npm ERR! npm v3.5.4 npm ERR! code ELIFECYCLE npm ERR! App@1.0.0 build:prod: `npm run build -- --prod "--aot"` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the App@1.0.0 build:prod script 'npm run build -- --prod "--aot"'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the App package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! npm run build -- --prod "--aot" npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs App npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls App npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /builds/mibzman/App/web/npm-debug.log npm info lifecycle App@1.0.0~build:prod:aot: Failed to exec build:prod:aot script npm ERR! Linux 4.4.0-78-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build:prod:aot" npm ERR! node v7.10.0 npm ERR! npm v4.2.0 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! App@1.0.0 build:prod:aot: `npm run build:prod -- --aot` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the App@1.0.0 build:prod:aot script 'npm run build:prod -- --aot'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the App package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! npm run build:prod -- --aot npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs App npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls App npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /root/.npm/_logs/2017-05-28T00_13_01_172Z-debug.log ERROR: Build failed: exit code 1 

究竟是什么导致了这个错误?