Angular:无法构建应用程序

时间:2018-07-24 11:38:14

标签: angular typescript webpack angular6 asp.net-core-2.1

我正在使用asp.net core 2.1开发angular6应用。

在使用ng build --prod构建项目时,我遇到了以下错误,但是如果我运行该项目,则它可以正常运行:

  

模块构建中的错误失败:TypeError:无法读取属性   “替换”未定义

     
      
  • 位于normalizeBackSlashDirection(D:\ New Loc \ Angular6_Core_2 \ WebApplication1 \ WebApplication1 \ ClientApp \ node_modules \ webpack \ lib \ RequestShortener.js:15:17)

  •   
  • 位于新的RequestShortener(D:\ New Loc \ Angular6_Core_2 \ WebApplication1 \ WebApplication1 \ ClientApp \ node_modules \ webpack \ lib \ RequestShortener.js:25:15)

  •   
  • 在新的编译器上(D:\ New Loc \ Angular6_Core_2 \ WebApplication1 \ WebApplication1 \ ClientApp \ node_modules \ webpack \ lib \ Compiler.js:136:27)
  •   
  • 在Compiler.createChildCompiler(D:\ New Loc \ Angular6_Core_2 \ WebApplication1 \ WebApplication1 \ ClientApp \ node_modules \ webpack \ lib \ Compiler.js:371:25)
  •   
  • 在Compilation.createChildCompiler(D:\ New Loc \ Angular6_Core_2 \ WebApplication1 \ WebApplication1 \ ClientApp \ node_modules \ webpack \ lib \ Compilation.js:1851:24)
  •   
  • 在Object.pitch(D:\ New Loc \ Angular6_Core_2 \ WebApplication1 \ WebApplication1 \ ClientApp \ node_modules \ mini-css-extract-plugin \ dist \ loader.js:78:43)
  •   

编辑:

Package.json:

{
  "name": "WebApplication1",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build:ssr": "npm run build -- --app=ssr --output-hashing=media",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.9",
    "@angular/common": "^6.0.9",
    "@angular/compiler": "^6.0.9",
    "@angular/core": "^6.0.9",
    "@angular/forms": "^6.0.9",
    "@angular/http": "^6.0.9",
    "@angular/platform-browser": "^6.0.9",
    "@angular/platform-browser-dynamic": "^6.0.9",
    "@angular/platform-server": "^6.0.9",
    "@angular/router": "^6.0.9",
    "@aspnet/signalr": "^1.0.2",
    "@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
    "@swimlane/ngx-charts": "^9.0.0",
    "@swimlane/ngx-datatable": "^13.0.1",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "jquery": "^3.3.1",
    "ngx-loading": "^1.0.14",
    "ngx-toastr": "^8.8.0",
    "primeng": "^6.0.0",
    "rxjs": "^6.2.2",
    "stacktrace-js": "^2.0.0",
    "sweetalert2": "^7.24.4",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "^6.0.8",
    "@angular/compiler-cli": "^6.0.9",
    "@angular/language-service": "^6.0.9",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2",
    "@angular-devkit/build-angular": "~0.6.8"
  },
  "optionalDependencies": {
    "node-sass": "^4.9.0"
  }
}

1 个答案:

答案 0 :(得分:0)

尝试一下:

ng build --env=prod