Hi,
ERROR in ./server.ts
Module build failed: TypeError: Cannot read property 'afterCompile' of undefined
at successfulTypeScriptInstance (D:\test\ang\node_modules\ts-loader\dist\instances.js:147:28)
at Object.getTypeScriptInstance (D:\test\ang\node_modules\ts-loader\dist\instances.js:48:12)
at Object.loader (D:\test\ang\node_modules\ts-loader\dist\index.js:16:41)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] webpack:server: webpack --config webpack.server.config.js --progress --colors
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] webpack:server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I receive this error when I try to run "webpack --config webpack.server.config.js --progress --colors"
@mehdi550u, this sounds like it might be a version mismatch聽in webpack. Could you confirm the versions of webpack and ts-loader your project is using?
@rjz
These are all my dependencies:
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/platform-server": "^5.2.6",
"@angular/router": "^5.2.0",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"ts-loader": "^4.0.0",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.1",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"'@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.5.3"
}
same problem here:
"ts-loader": "^4.0.0",
"typescript": "^2.7.2",
"webpack": "^4.0.0",
"webpack-cli": "^2.0.9",
I resolved this by setting webpack to 3.10.0 and ts-loader back to 3.5.0, see here https://github.com/TypeStrong/ts-loader/releases
I'm sorry, but this issue is not caused by Angular CLI. Please contact the author(s) of the https://github.com/TypeStrong/ts-loader project or file an issue on their issue tracker.
Change "ts-loader": "^3.5.0" and reinstall dependencies.
See ts-loader compatibility
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
I resolved this by setting webpack to 3.10.0 and ts-loader back to 3.5.0, see here https://github.com/TypeStrong/ts-loader/releases