【问题标题】:Angular : Unable to build applicationAngular:无法构建应用程序
【发布时间】:2019-01-01 00:25:26
【问题描述】:

我正在使用 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)处

编辑:

包.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"
  }
}

【问题讨论】:

  • 您应该在其中一个 html 模板中为字段 replace 绑定,并且该属性在组件中不存在。
  • 不,它不在任何页面中,我用“替换”搜索
  • 也许你正在链接一个不存在的 css 或其他样式文件
  • 运行 npm i 并重试
  • @LahiruChandima 这是一个 webpack 问题,如跟踪中所述。所以是图书馆问题,而不是项目问题。

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


【解决方案1】:

试试这个:

ng build --env=prod

【讨论】:

  • 未知选项:'--env'
  • Angular 6 是 --configuration=prod,但您可以缩短为 --prod
猜你喜欢
  • 1970-01-01
  • 2018-01-16
  • 2018-02-09
  • 2017-08-10
  • 2018-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多