我在我的 angular 2
项目中使用 webpack
。它与 npm
一起工作正常,但是在安装 npm install -g angular-cli
之后,当我使用 `ng' 命令创建组件或构建时,它显示以下错误。
ERROR in TypeError: Cannot read property 'request' of undefined
ExternalModuleFactoryPlugin.js:37 handleExternals [BackofficeVidapayCRM]/[webpack]/lib/ExternalModuleFactoryPlugin.js:37:33
ExternalModuleFactoryPlugin.js:46 next [BackofficeVidapayCRM]/[webpack]/lib/ExternalModuleFactoryPlugin.js:46:8
ExternalModuleFactoryPlugin.js:59 handleExternals [BackofficeVidapayCRM]/[webpack]/lib/ExternalModuleFactoryPlugin.js:59:7
ExternalModuleFactoryPlugin.js:79 ExternalModuleFactoryPlugin. [BackofficeVidapayCRM]/[webpack]/lib/ExternalModuleFactoryPlugin.js:79:5
NormalModuleFactory.js:207 [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/NormalModuleFactory.js:20 7:3
Tapable.js:168 [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:168:11
NormalModuleReplacementPlugin.js:26 NormalModuleFactory. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/NormalModuleReplacementPl ugin.js:26:11
Tapable.js:172 NormalModuleFactory.applyPluginsAsyncWaterfall [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:172:13
NormalModuleFactory.js:191 NormalModuleFactory.create [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/NormalModuleFactory.js:19 1:8
Compilation.js:359 Compilation.process [as _addModuleChain] [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compilation.js:359:16
Compilation.js:435 Compilation.process [as addEntry] [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compilation.js:435:7
SingleEntryPlugin.js:22 SingleEntryPlugin. [BackofficeVidapayCRM]/[webpack]/lib/SingleEntryPlugin.js:22:15
Tapable.js:193 Compiler.applyPluginsParallel [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:193:14
Compiler.js:463 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:463:8
Tapable.js:95 Compiler.applyPluginsAsyncSeries [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:95:46
Compiler.js:456 Compiler.compile [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:456:7
Compiler.js:265 Compiler.runAsChild [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:265:7
compiler.js:70 [BackofficeVidapayCRM]/[html-webpack-plugin]/lib/compiler.js:70:19
debuggability.js:299 Promise._execute [BackofficeVidapayCRM]/[bluebird]/js/release/debuggability.js:299:9
promise.js:481 Promise._resolveFromExecutor [BackofficeVidapayCRM]/[bluebird]/js/release/promise.js:481:18
promise.js:77 new Promise [BackofficeVidapayCRM]/[bluebird]/js/release/promise.js:77:14
compiler.js:69 Object.compileTemplate [BackofficeVidapayCRM]/[html-webpack-plugin]/lib/compiler.js:69:10
index.js:47 Compiler. [BackofficeVidapayCRM]/[html-webpack-plugin]/index.js:47:40
Tapable.js:193 Compiler.applyPluginsParallel [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:193:14
Compiler.js:463 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:463:8
Tapable.js:95 Compiler.applyPluginsAsyncSeries [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:95:46
Compiler.js:456 Compiler.compile [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:456:7
Compiler.js:219 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:219:10
Compiler.js:367 Compiler.readRecords [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:367:10
Compiler.js:216 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:216:9
Tapable.js:102 next [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:102:11
CachePlugin.js:34 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/CachePlugin.js:34:58
Tapable.js:106 Compiler.applyPluginsAsyncSeries [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:106:13
Compiler.js:213 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:213:8
Tapable.js:102 next [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:102:11
NodeEnvironmentPlugin.js:23 Compiler. [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/node/NodeEnvironmentPlugi n.js:23:3
Tapable.js:106 Compiler.applyPluginsAsyncSeries [BackofficeVidapayCRM]/[tapable]/lib/Tapable.js:106:13
Compiler.js:210 Compiler.run [BackofficeVidapayCRM]/[angular-cli]/[webpack]/lib/Compiler.js:210:7
build-webpack.js:21 [BackofficeVidapayCRM]/[angular-cli]/tasks/build-webpack.js:21:29
build-webpack.js:20 Class.run [BackofficeVidapayCRM]/[angular-cli]/tasks/build-webpack.js:20:16
build.js:54 Class.run [BackofficeVidapayCRM]/[angular-cli]/commands/build.js:54:26
command.js:152 Class. [BackofficeVidapayCRM]/[angular-cli]/angular-cli/lib/models/command.js:152:17
next_tick.js:103 process._tickCallback internal/process/next_tick.js:103:7
package.json:
{
"name": "starter",
"version": "0.0.0",
"license": "MIT",
"angular-cli": { },
"scripts": {
"start": "ng serve \"npm run server\"",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"typings-install": "typings install",
"postinstall": "npm run typings-install",
"build": "webpack --inline --colors --progress --display-error-details --display-cached",
"server": "webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src"
},
"private": true,
"dependencies": {
"@angular/common": "2.2.3",
"@angular/compiler": "2.2.3",
"@angular/core": "2.2.3",
"@angular/forms": "2.2.3",
"@angular/http": "2.2.3",
"@angular/platform-browser": "2.2.3",
"@angular/platform-browser-dynamic": "2.2.3",
"@angular/router": "3.2.3",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"animate.css": "3.1.1",
"bootstrap": "^3.3.7",
"font-awesome": "^4.6.1",
"ie-shim": "^0.1.0",
"jquery": "^3.1.0",
"metismenu": "^2.5.0",
"pace": "0.0.4",
"pace-progress": "^1.0.2",
"reflect-metadata": "^0.1.3",
"systemjs": "0.19.27"
},
"devDependencies": {
"@angular/compiler-cli": "2.2.3",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.22-1",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"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",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "^4.0.2",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5",
"angular2-template-loader": "^0.6.0",
"awesome-typescript-loader": "^3.0.0-beta.13",
"bootstrap-webpack": "0.0.5",
"css-loader": "^0.26.1",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"imports-loader": "^0.7.0",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5",
"typings": "^2.0.0",
"url-loader": "^0.5.7",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2",
"webpack-merge": "^1.1.1"
}
}
请帮我解决这个问题。
最佳答案
你可以检查你路径上的 package.json 看看你的 webpack 版本是否太低,我只是将我的 webpack 版本更新到 2.x,然后再次尝试'npm install webpack --save-dev',它有效
关于angular - 类型错误 : Cannot read property 'request' of undefined with angular-cli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41120462/