Skip to content

Bug: Runtime TypeError ("Cannot read property 'call' of undefined") #6196

Closed
@ghost

Description

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..."):
image
Webpack is trying to get the module with the Id 0:
image
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulhelp wantedneeds: investigationRequires some digging to determine if action is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions