2017-07-08 9 views
39

が定義されていません。私はスーパーテンプレートでプロジェクトを開始しました。しかし、私はブラウザでアプリを実行しようとすると。イオン2:にReferenceError:webpackJsonpは、私はイオン性に新たなんだ

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

私はindex.htmlにvendor.jsを入れてみましたが、うまくいきませんでした。

ここでindex.htmlファイルです。私はvendor.jsを削除しましたが、うまくいきませんでした。

<!DOCTYPE html> 
<html lang="en" dir="ltr"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Ionic App</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
    <meta name="format-detection" content="telephone=no"> 
    <meta name="msapplication-tap-highlight" content="no"> 

    <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico"> 
    <link rel="manifest" href="manifest.json"> 
    <meta name="theme-color" content="#4e8ef7"> 

    <!-- cordova.js required for cordova apps --> 
    <script src="cordova.js"></script> 

    <!-- un-comment this code to enable service worker 
    <script> 
    if ('serviceWorker' in navigator) { 
     navigator.serviceWorker.register('service-worker.js') 
     .then(() => console.log('service worker installed')) 
     .catch(err => console.log('Error', err)); 
    } 
    </script>--> 

    <link href="build/main.css" rel="stylesheet"> 

</head> 
<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 bundle js is generated during the build process --> 
    <script src="build/main.js"></script> 

</body> 
</html> 
+0

よう

<script src="build/polyfills.js"></script> 

後これは主ですプロジェクトはコード分割を使用しており、webpackのコードは 'main.js'チャンクの後にロードされました – thangngoc89

+0

詳細情報を提供できますか?このエラーは、コードがまだwebpackランタイムをロードしていないことを意味しますが、指定された情報に基づいて理由を伝えることは不可能です。 –

+0

vendor.jsを削除したらどういう意味ですか?かなり確信してのWebPACKのランタイムは – thangngoc89

答えて

85

文字通りちょうどあなたと同じことを行った。私は/src/index.htmlにmain.js前vendor.jsスクリプトを追加しました - 今、それがローカルに実行されます。

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

    <script src="build/vendor.js"></script> 

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

私はやったが、うまくいかなかった。アプリを削除して、もう一度空のテンプルでプロジェクトを開始してください。 –

+3

それはそれはそれは私のために働いた – alokj03

+4

のために働きました。 – sebaferreras

45

これは、イオン性のApp-スクリプトで互換性に影響する変更は

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

のsrc/index.htmlには、新しいベンダーのスクリプトタグを含むように修正されなければならないです。

... 
<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> 
... 
11

また< your application directory >/src/service-worker.jsファイルに変更を加えること< your application directory > /src/index.html

<script src="build/vendor.js"></script> 

にスクリプトタグ内vendor.jsパスを追加します - precacheセクションでvendor.jsを含める:

// pre-cache our key assets 
self.toolbox.precache(
    [ 
     './build/main.js', 
     './build/vendor.js', // <=== Add vendor.js 
     './build/main.css', 
     './build/polyfills.js', 
     'index.html', 
     'manifest.json' 
    ] 
); 
+0

私はself.toolbox.precache(...を持っていなかった); in /src/service-worker.jsこの苦情の前にvendor.js index.htmへのアップデートは、service-worker.jsを変更せずにランタイムエラーを処理しているようです。 それはどういう意味ですか"これらの資産をプリキャッシュする"?アンドロイドのようなプラットフォームの構築だけでなく、PWAの展開にも適用されますか? – Marie

4

私はときに、同じ問題に直面しています私はイオン3で古いイオン2プロジェクトを開発し始めた。 このsteに従いなさいpsは私のために働く。 src\index.html opneが

<script src="build/main.js"></script> 

<script src="build/vendor.js"></script> 

この行を入れているので、この

<!DOCTYPE html> 
... 
<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> 
    <script src="build/vendor.js"></script> <---- here 
    <!-- The bundle js is generated during the build process --> 
    <script src="build/main.js"></script> 

</body> 

</html> 
関連する問題