Bug: Runtime TypeError ("Cannot read property 'call' of undefined")
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
General information
We have an Angular 2 application running and I was asked to upgrade Angular (including it's CLI) to the newest version (Note: I'm not really involved in the project, so I don't know how the application is built or where the dependencies are used). I tried upgrading using the 1.0 update guide. Building the app with ng build works (no error messages), but when I navigate to the website, I get an error message in the console.
Versions
@angular/cli: 1.0.2
node: 7.9.0
os: win32 x64
@angular/animations: 4.1.1
@angular/common: 4.1.1
@angular/compiler: 4.1.1
@angular/core: 4.1.1
@angular/forms: 4.1.1
@angular/http: 4.1.1
@angular/platform-browser: 4.1.1
@angular/platform-browser-dynamic: 4.1.1
@angular/router: 4.1.1
@angular/cli: 1.0.2
@angular/compiler-cli: 4.1.1
Repro steps / packages
I don't know what exactly causes this issue, therefore I don't know how to reproduce it. packages.json
...
"dependencies": {
"@angular/animations": "^4.1.1",
"@angular/common": "^4.1.1",
"@angular/compiler": "^4.1.1",
"@angular/core": "^4.1.1",
"@angular/forms": "^4.1.1",
"@angular/http": "^4.1.1",
"@angular/platform-browser": "^4.1.1",
"@angular/platform-browser-dynamic": "^4.1.1",
"@angular/router": "^4.1.1",
"@ngx-translate/core": "^6.0.1",
"@webcomponents/custom-elements": "^1.0.0-rc.3",
"clarity-angular": "^0.9.3",
"clarity-icons": "^0.9.3",
"clarity-ui": "^0.9.3",
"core-js": "^2.4.1",
"moment": "^2.18.1",
"mutationobserver-shim": "^0.3.2",
"ng2-file-upload": "^1.2.1",
"ngx-bootstrap": "^1.6.6",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.3.1",
"web-animations-js": "^2.2.5",
"zone.js": "^0.8.10"
},
"devDependencies": {
"@angular/cli": "~1.0.2",
"@angular/compiler-cli": "^4.1.1",
"@types/jasmine": "2.5.47",
"@types/node": "~7.0.18",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~3.0.4",
"tslint": "~5.2.0",
"typescript": "~2.2.0",
"webpack": "~2.5.0"
}
}
.angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
...
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../../Content/less/clarity/datagrid.css",
"../node_modules/clarity-icons/clarity-icons.min.css",
"styles.css"
],
"scripts": [
"../node_modules/core-js/client/shim.min.js",
"../node_modules/mutationobserver-shim/dist/mutationobserver.min.js",
"../node_modules/@webcomponents/custom-elements/custom-elements.min.js",
"../node_modules/clarity-icons/clarity-icons.min.js",
"../node_modules/web-animations-js/web-animations.min.js",
"../node_modules/reflect-metadata/Reflect.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
...
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
The log given by the failure
I get this console error message at runtime (application is then stuck at "Loading..."):
Webpack is trying to get the module with the Id 0:
modules[0] is undefined though.
Although when checking stats.json using the webpack analyzer, the module with the id 0 (./~/@angular/core/@angular/core.es5.js) exists.
Desired functionality
Proper bootstrapping of the application.
Mention any other details that might be useful
Someone had a similar problem and according to sokra this issue was fixed in 2.5.0. I got version 2.5.0 of webpack and put it manually in the node_modules folder of angular cli but the issue still persists. When I create a new application using ng new [name], it works fine. As soon as I put my src files and my dependencies in there I get this error.
In my case order was the issue. Mine zone.js version is 0.8.19. The issue is still reproducible if I change the scripts order.
I see this issue in my project when using ng serve --aot on rebuilds.
Same, my lazy-loaded modules are throwing this error on rebuilds using ng serve --aot. If I terminate the process and build from scratch it's not an issue.
Same issue as @AndrewEckart, getting frustrated having to kill and restart an aot build every time I make changes
Ionic is still as it is for long time: a lazy stitched broken bunch of crappy code without the need of doing anything professional. Everything they touch, even their professional services for which I have subscribed are loaded with bugs. They are always running AFTER new tech and features but for what reason? Bad design choices, bad community handling. Ionic is using their community to fix bugs and thats it, they pushing the nerve of their peer members to the limits to find out if someone will do the fixing for them. Rolling out Ionic4....already? Make one release stable for god sake. Ionic team please do less so we can both achieve more.
I am getting the same error when using ng build --watch on aot and enabled sourcemaps.
We have the same error as @AndrewEckart, everything serves fine, but on rebuild, the error is thrown
Same Issue, fixes when rebuild application, problem occurs when for example move a module to another folder.
The solution for me was rather simple. Clear cache and hard reload. This seems to happen when I add a new page or service and don't restart the dev server.
Looks like it's related to the view engine compiler. With the transition to ivy, this will hopefully be fixed in the next months.
Closing the issue for now but we should definitely revisit it once we release ngtsc. The workarounds from above provide a sufficient solution for now. The cold webpack start would also get faster in webpack v5, so the inconvenience from the build restart will drop further.
Still, if I'm missing anything, feel free to create a new issue with details and demo where we can reproduce the problem.
Hey guys, i just fixed it for me
My problem was, that i included the
*.bundle.jsfiles in the wrong order. I loaded them dynamically via PHP (because of the different hashes generated in the prod version) and included them in my blade.php file (alphabetically by default)@foreach($jsBundles as $bundle)
@Endforeach
I was wondering why
ng serveworked butng prodnot so i included them in this orderinline.bundle.js polyfills.bundle.js scripts.bundle.js vendor.bundle.js main.bundle.js
And now it is working again. Maybe it will help one or another
Was this for entry field there should follow this order. SomeWhere else.
I did have a webpack version 4.8.3.
I changed my webpack.config.js to export a function instead of an object and then I ran the command npm install webpack@latest
The webpack version 4.33.0 (after I did npm install webpack@latest -> 4.33.0) seems to have the fix for this.
Boom my issue was resolved.
The one thing I dont understand is that the I havent changed any configuration nor I have changed any code since 60days prior to todays date(june 4th). This version of webpack seems to have some issue that did not come up when I first started using it.
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.