Ionic 2: ReferenceError: webpackJsonp is not defined

Ionic 2的代码在Ionic 5的环境下运行,提示如下错误:

ReferenceError: webpackJsonp is not defined
    at http://localhost:8100/build/main.js:1:1

查找资料发现是Ionic新版本的一些改变引起的,需要在Index.htm引入build/vendor.js

具体说明如下:

This is a breaking change in Ionic-App-Scripts

https://github.com/ionic-team/ionic-app-scripts/releases/tag/v2.0.0

src/index.html must be modified to include a new vendor script tag .

改成:

...
<body>

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

  <script src="cordova.js"></script>

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

  <!-- all code from node_modules directory is here -->
  <script src="build/vendor.js"></script>

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

</body>
...
原文地址:https://www.cnblogs.com/colder/p/11822362.html