简体   繁体   English

Angular 4:ng服务正常,但是ng build --prod失败

[英]Angular 4: ng serve work well but ng build --prod fails

When I tried to run ng serve it runs without any error, but when I tried to create a production build using ' ng build --prod ' it stopped with error below. 当我尝试运行ng serve它运行时没有任何错误,但是当我尝试使用' ng build --prod '创建生产版本时,它停止并显示以下错误。 I tried to tweak with the version still no success. 我尝试调整版本仍然没有成功。 Then some other issue occurred like other API version compatibility issue. 然后发生了其他一些问题,例如其他API版本兼容性问题。 Any help will be highly appreciated. 任何帮助将不胜感激。

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\\000PS\\workspace_ui\\dashboard\\src' ERROR in Error: Metadata version mismatch for module D:/000PS/workspace_ui/dashboard/node_modules/ngx-pipes/src/app/index.d.ts, found version 4, expected 3 at StaticSymbolResolver.getModuleMetadata (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:25755:34) at StaticSymbolResolver._createSymbolsOf (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:25543:46) at StaticSymbolResolver.getSymbolsOf (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:25524:14) at D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:24381:30 at Array.forEach () at extractProgramSymbols (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:24380:79) at AotCompiler.analyzeModulesAsync (D:\\000PS\\w 找不到./src/main.ts模块中的错误:错误:无法解析'D:\\ 000PS \\ workspace_ui \\ dashboard \\ src中的'./$$_gendir/app/app.app.module.ngfactory'错误中的错误:模块D:/000PS/workspace_ui/dashboard/node_modules/ngx-pipes/src/app/index.d.ts的元数据版本不匹配,发现版本4,预期在StaticSymbolResolver.getModuleMetadata中为3(D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler \\ bundles \\ compiler.umd.js:25755:34)在StaticSymbolResolver._createSymbolsOf(D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler \\ bundles \\ compiler.umd.js:25543 :46)在StaticSymbolResolver.getSymbolsOf(D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler \\ bundles \\ compiler.umd.js:25524:14)在D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler \\ bundles \\ compiler.umd.js:24381:30 at Array.forEach()在extractProgramSymbols(D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler \\ bundles \\ compiler.umd.js:24380:79 )在AotCompiler.analyzeModulesAsync(D:\\ 000PS \\ w orkspace_ui\\dashboard\\node_modules\\@angular\\compiler\\bundles\\compiler.umd.js:23936:47) at CodeGenerator.codegen (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler-cli\\src\\codegen.js:32:14) at Function.NgTools_InternalApi_NG_2.codeGen (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@angular\\compiler-cli\\src\\ngtools_api.js:73:30) at _donePromise.Promise.resolve.then (D:\\000PS\\workspace_ui\\dashboard\\node_modules\\@ngtools\\webpack\\src\\plugin.js:428:58) at at process._tickCallback (internal/process/next_tick.js:188:7) 在CodeGenerator.codegen(D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler-cli \\ src \\ codegen处的orkspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler \\ bundles \\ compiler.umd.js:23936:47)。 js:32:14)在Function.NgTools_InternalApi_NG_2.codeGen(D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @angular \\ compiler-cli \\ src \\ ngtools_api.js:73:30)在_donePromise.Promise.resolve.then( D:\\ 000PS \\ workspace_ui \\ dashboard \\ node_modules \\ @ngtools \\ webpack \\ src \\ plugin.js:428:58)在进程中._tickCallback(内部/进程/next_tick.js:188:7)

Please find package.json for reference: 请找到package.json以供参考:

{
  "name": "dashboard",
  "version": "1.0.1",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "4.4.4",
    "@angular/compiler": "4.4.4",
    "@angular/core": "4.4.4",
    "@angular/forms": "4.4.4",
    "@angular/http": "4.4.4",
    "@angular/platform-browser": "4.4.4",
    "@angular/platform-browser-dynamic": "4.4.4",
    "@angular/router": "4.4.4",
    "@ngui/map": "0.18.3",
    "@types/googlemaps": "3.26.14",
    "angular2-jwt": "^0.2.3",
    "bootstrap": "3.3.5",
    "bootstrap-notify": "3.1.3",
    "bootstrap-select": "1.12.2",
    "bootstrap-switch": "3.3.4",
    "bootstrap-tagsinput": "0.7.1",
    "chartist": "0.9.4",
    "chartist-plugin-zoom": "0.4.0",
    "chartjs-plugin-zoom": "0.5.0",
    "core-js": "2.4.1",
    "datatables": "1.10.12",
    "datatables.net-bs": "1.10.12",
    "datatables.net-responsive": "2.1.1",
    "easy-pie-chart": "2.1.7",
    "eonasdan-bootstrap-datetimepicker": "4.17.47",
    "fullcalendar": "3.4.0",
    "jasny-bootstrap": "3.1.3",
    "jquery": "1.12.4",
    "material-design-icons": "^3.0.1",
    "mdbootstrap": "^4.5.0",
    "ng2-fab-speed-dial": "^1.0.0-beta.5",
    "ngx-pipes": "^1.6.5",
    "nouislider": "9.2.0",
    "npm": "^5.8.0",
    "rxjs": "5.4.2",
    "time-ago-pipe": "1.2.1",
    "twitter-bootstrap-wizard": "^1.2.0",
    "web-animations-js": "2.2.2",
    "zone.js": "0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.4",
    "@angular/compiler-cli": "4.4.4",
    "@types/bootstrap": "3.3.32",
    "@types/chartist": "0.9.34",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "1.10.31",
    "@types/node": "6.0.73",
    "angular2-jwt": "^0.2.3",
    "codelyzer": "2.0.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",
    "protractor": "5.1.0",
    "ts-node": "2.0.0",
    "tslint": "4.5.0",
    "typescript": "2.4.2"
  }
}

Your angular version is 4.4 and ngx-pipes angular version is 5 or above. 您的角度版本为4.4,而ngx-pipes角度版本为5或更高。 So install ngx-pipes with version that is compatible with your angular project. 因此,请安装与Angular项目兼容的ngx-pipes版本。

Check inside node_modules/ngx-pipes/package.json to find ngx-pipes version. 检查node_modules / ngx-pipes / package.json内部以找到ngx-pipes版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM