Ionic - ReferenceError: Can't find variable: webpackJsonp

Hello,

after last update of my Ionic app libraries I have seen blank white page in emulator and error in console: ReferenceError: Can’t find variable: webpackJsonp

I had no idea what could be causing this. After pointless googling I tried to create a new Ionic project. Apparently from version 2.0 file /src/index.html have been changed! Body now should look like this - new is file build/vendor.js

<body>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>

</body>

This solved my problem. It would be nice to have some warning if build/vendor.js is not included …

PS: currently Ionic is not working with typescript version 2.4.1 - so don`t waste time with updating … It have some new code checks which will find errors in Ionic core libraries and build fails.

6 Likes

The need for vendor.js is in the Ionic changelog for framework 3.5. And yeah, only use the exact version of Typescript recommended. In general, only use ^ in package.json for libraries that Ionic does not need as a peer.

3 Likes

Thanks for the tip. Additionally, for those upgrading to the very latest release running ng 5 from an older version, you may have to add the BrowserModule from @angular/platform-browser in your app.module.ts:

import { BrowserModule } from '@angular/platform-browser';

// Above your Ionic import in NgModule:
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],