javascript - 类型错误 : Cannot read property 'match' of undefined 中的错误

标签 javascript node.js angular typescript webpack

我正在尝试为 Angular 2 项目创建生产版本。我在 ng-build -prod 命令中遇到此错误..

从命令 **ng build -prod 记录。**

ERROR in TypeError: Cannot read property 'match' of undefined

suppress-entry-chunks-webpack-plugin.js:40 filterFn
[Angular_whiskey]/[@angular]/cli/plugins/suppress-entry-chunks-webpack-plugin.js:40:91

Array.filter

suppress-entry-chunks-webpack-plugin.js:42 Compilation.compilation.plugin
[Angular_whiskey]/[@angular]/cli/plugins/suppress-entry-chunks-webpack-plugin.js:42:59

Tapable.js:208 Compilation.applyPluginsAsyncWaterfall
[Angular_whiskey]/[tapable]/lib/Tapable.js:208:13

util.js:16 Compilation.tryCatcher
[Angular_whiskey]/[bluebird]/js/release/util.js:16:23

index.js:642
[Angular_whiskey]/[html-webpack-plugin]/index.js:642:12

index.js:152
[Angular_whiskey]/[html-webpack-plugin]/index.js:152:16

util.js:16 tryCatcher
[Angular_whiskey]/[bluebird]/js/release/util.js:16:23

promise.js:512 Promise._settlePromiseFromHandler
[Angular_whiskey]/[bluebird]/js/release/promise.js:512:31

promise.js:569 Promise._settlePromise
[Angular_whiskey]/[bluebird]/js/release/promise.js:569:18

promise.js:614 Promise._settlePromise0
[Angular_whiskey]/[bluebird]/js/release/promise.js:614:10

promise.js:693 Promise._settlePromises
[Angular_whiskey]/[bluebird]/js/release/promise.js:693:18

async.js:133 Async._drainQueue
[Angular_whiskey]/[bluebird]/js/release/async.js:133:16

async.js:143 Async._drainQueues
[Angular_whiskey]/[bluebird]/js/release/async.js:143:10

async.js:17 Immediate.Async.drainQueues
[Angular_whiskey]/[bluebird]/js/release/async.js:17:14

通过 ng-serve 在本地部署应用程序效果很好。然而,ng build -prod 却没有。任何帮助将不胜感激。我认为我的 Angular 包之间存在版本不匹配。

版本。

@angular/cli: 1.0.0-rc.4
node: 7.0.0
os: win32 x64
@angular/cli: 1.0.0-rc.4
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/compiler-cli: 4.0.0-rc.5
@ngtools/webpack: 1.2.14

重现步骤。

ng build-prod

package.json

{
"name": "angular-whiskey",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "node server.js",
"lint": "tslint "src/**/*.ts"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"postinstall": "ng build --aot -prod"
},
"private": true,
"engines": {
"node": "7.0.0",
"npm": "4.4.1"
},
"dependencies": {
"@angular/cli": "^1.0.0-rc.2",
"@angular/common": "2.4.7",
"@angular/compiler": "2.4.7",
"@angular/core": "2.4.7",
"@angular/forms": "2.4.7",
"@angular/http": "2.4.7",
"@angular/platform-browser": "2.4.7",
"@angular/platform-browser-dynamic": "2.4.7",
"@angular/router": "3.4.7",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.20",
"@ngtools/webpack": "^1.2.4",
"@types/core-js": "^0.9.37",
"@types/jasmine": "^2.5.38",
"@types/node": "^6.0.65",
"angularfire2": "^2.0.0-beta.7-pre",
"auth0-lock": "^10.13.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"express": "^4.15.2",
"firebase": "^3.7.1",
"ng2-bootstrap": "^1.4.0",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"typescript": "2.2.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@angular/cli": "^1.0.0-rc.4",
"@angular/compiler-cli": "4.0.0-rc.5",
"@types/core-js": "^0.9.34",
"@types/jasmine": "^2.2.30",
"@types/node": "^6.0.42",
"codelyzer": "1.0.0-beta.1",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"node-sass": "^3.10.1",
"protractor": "4.0.9",
"raw-loader": "^0.5.1",
"sass-loader": "^4.0.2",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
}
}

最佳答案

ERROR in TypeError: Cannot read property 'match' of undefined

这不是您的代码中的错误。这是 suppress-entry-chunks-webpack-plugin.js:40 filterFn

中的错误

向 Angular 团队提出问题🌹 ([Angular_whiskey]/[@angular]/cli/plugins/suppress-entry-chunks-webpack-plugin.js)

关于javascript - 类型错误 : Cannot read property 'match' of undefined 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42954767/

相关文章:

javascript - 使用相关模型字段的环回过滤器

javascript - Jasmine 测试 Backbone 查看事件

javascript - 在 JavaScript 警报()中打印 EL 字符串 "RP"会导致 JS 错误 "' RP' 未定义”

javascript - 如何使用 d3 + socket.io 进行平滑过渡

security - 如何保护 Node.JS Web 套接字服务器免受连接炸弹的侵害?

javascript - 在哪里放置全局帮助 js 函数

angular - 是否可以在 Angular 组件模板中使用 let 为变量赋值?

angular - inject() 必须从注入(inject)上下文中调用

javascript - 无法在 Angular2 测试中运行服务(从文档粘贴的代码副本)

node.js - 有没有一种方法可以在没有 CLI 的情况下运行 Nodejs 脚本?