Cannot read property 'thisCompilation' of undefined

一、启动angular项目时,发现如下error:

Cannot read property 'thisCompilation' of undefined
TypeError: Cannot read property 'thisCompilation' of undefined
    at NodeTemplatePlugin.apply (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\webpack\lib\node\NodeTemplatePlugin.js:19:18)
    at Compiler.apply (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\tapable\lib\Tapable.js:375:16)
    at Object.compileTemplate (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\html-webpack-plugin\lib\compiler.js:48:17)
    at Compiler. (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\html-webpack-plugin\index.js:47:40)
    at Compiler.applyPluginsParallel (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\tapable\lib\Tapable.js:293:14)
    at applyPluginsAsync.err (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\@angular\cli\node_modules\webpack\lib\Compiler.js:503:9)
    at Compiler.applyPluginsAsyncSeries (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\tapable\lib\Tapable.js:195:46)
    at Compiler.compile (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\@angular\cli\node_modules\webpack\lib\Compiler.js:496:8)
    at compiler.applyPluginsAsync.err (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\@angular\cli\node_modules\webpack\lib\Compiler.js:82:18)
    at next (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\tapable\lib\Tapable.js:202:11)
    at Compiler.compilerInvalid (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\webpack-dev-middleware\lib\Shared.js:161:5)
    at next (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\tapable\lib\Tapable.js:204:14)
    at Compiler.compiler.plugin (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\@angular\cli\node_modules\webpack\lib\CachePlugin.js:48:5)
    at Compiler.applyPluginsAsyncSeries (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\tapable\lib\Tapable.js:206:13)
    at Watching._go (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\@angular\cli\node_modules\webpack\lib\Compiler.js:47:17)
    at Watching.compiler.readRecords.err (C:\D\SGM\Workspace\gitPro\ng2-project\node_modules\@angular\cli\node_modules\webpack\lib\Compiler.js:39:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `ng serve  --environment=dev --live-reload=false --proxy-config proxy.conf.dev.js `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jzhang3\AppData\Roaming\npm-cache\_logs\2018-05-14T02_59_07_807Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `npm run dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\jzhang3\AppData\Roaming\npm-cache\_logs\2018-05-14T02_59_07_839Z-debug.log


二、解决办法:

1. npm remove webpack

2. npm install --save-dev @angular/cli@latest

3. 重启即可

你可能感兴趣的:(解决方案)