angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

webpackJsonp is not defined

Open fabienbranchel opened this issue 9 years ago • 23 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report 
- [ ] feature request

Versions.

Output from: ng --version. @angular/cli: 1.4.6 node: 6.11.3 os: darwin x64 @angular/animations: 4.4.4 @angular/cdk: 2.0.0-beta.12 @angular/common: 4.4.4 @angular/compiler: 4.4.4 @angular/core: 4.4.4 @angular/forms: 4.4.4 @angular/http: 4.4.4 @angular/material: 2.0.0-beta.12 @angular/platform-browser: 4.4.4 @angular/platform-browser-dynamic: 4.4.4 @angular/router: 4.4.4 @angular/cli: 1.4.6 @angular/compiler-cli: 4.4.4 @angular/language-service: 4.4.4 @angular/service-worker: 1.0.0-beta.16 typescript: 2.3.4 macOS Sierra 10.12.6

Android Devices :

  • Samsung Galaxy S7 Edge, Android 7.0, Chrome 61.0.3163.98
  • Motorola Moto E4, Android 7.1.1, Chrome 61.0.3163.98
  • Pixel C, Android 8.0, Chrome 61.0.3163.98

Repro steps.

I have a webapp with a SW (generate by CLI), I build it with the "ng build --prod" command.

  • Open the webapp in Chrome on Android Device
  • Close Chrome
  • Repeat open (the webapp opened previously reload)/close Chrome few times, and the error happen

Important : I can't reproduce it without a registered SW.

OR

  • Install app on Android Device
  • Repeat open/close the app few times, and the error happen

I can't reproduce the error on my Mac.

The log given by the failure.

 Uncaught ReferenceError: webpackJsonp is not defined at sw-register.cddb6ecf3e30717910a9.bundle.js:1 

Desired functionality.

Webapp launch & display OK.

Mention any other details that might be useful.

I've already find this similar issue : https://github.com/angular/angular-cli/issues/4998 But my uglify version is 3.

fabienbranchel avatar Oct 12 '17 15:10 fabienbranchel

webpackJsonp is not defined usually mean you are not loading the javascript bundles in the right order. They must be loaded in the order present in the index.html that the CLI generates.

Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

filipesilva avatar Oct 16 '17 10:10 filipesilva

@filipesilva I meet the same issue after add jquery and bootstrap in webpack.config.js , i try to adjust the loading order ,but it didn‘t work. you can see the code here

thank you!

1111

https://github.com/angular/angular-cli/issues/7583

flyher avatar Oct 24 '17 02:10 flyher

Having the same issue here... building with -aot (dev) works fine. Prod compiles without complaint but when loading the app on the browser, it returns the following errors:

polyfills.900aaf0d520c2ec873a7.bundle.js:1 Uncaught ReferenceError: webpackJsonp is not defined
    at polyfills.900aaf0d520c2ec873a7.bundle.js:1
(anonymous) @ polyfills.900aaf0d520c2ec873a7.bundle.js:1
vendor.b3b1073e85b443c9b6c3.bundle.js:1 Uncaught ReferenceError: webpackJsonp is not defined
    at vendor.b3b1073e85b443c9b6c3.bundle.js:1
(anonymous) @ vendor.b3b1073e85b443c9b6c3.bundle.js:1
main.dfb485d3367f26ac4251.bundle.js:1 Uncaught ReferenceError: webpackJsonp is not defined
    at main.dfb485d3367f26ac4251.bundle.js:1
(anonymous) @ main.dfb485d3367f26ac4251.bundle.js:1

natcohen avatar Oct 25 '17 15:10 natcohen

I have same issue only on IE 11

LapassetAlexis avatar Nov 08 '17 10:11 LapassetAlexis

Same issue here.

oshingc avatar Nov 17 '17 20:11 oshingc

Same issue here, ng serve works fine, but ng build to deploy the app in bluemix is not working properly

yadoble avatar Dec 06 '17 20:12 yadoble

Same issue. Local build works fine loading both the localhost:4200 and localhost:4200/[viewcomponent].

As soon as I push it live: The base url works and navigating to other pages works as well however Loading a page directly gives the following error:

inline.7188b140d50c544cd4d6.bundle.js:1 
Uncaught SyntaxError: Unexpected token <

polyfills.900aaf0d520c2ec873a7.bundle.js:1 
Uncaught ReferenceError: webpackJsonp is not defined

vendor.945e35d73f0e55b0c5f4.bundle.js:1 
Uncaught SyntaxError: Unexpected token <

main.bd9155fd1f2baada6b7b.bundle.js:1 
Uncaught SyntaxError: Unexpected token <

royjulien avatar Dec 10 '17 04:12 royjulien

@filipesilva :

Time pass, I was using Workbox in production and then I try again with the release of Angular 5. I now use Angular 5.1, with Angular CI 1.6 and Angular Service Worker 5.0. The issue seems to be fix with my use case.

I proceed to a lot of tests in the same conditions than before with previouses versions, and all is working as expected.

fabienbranchel avatar Dec 14 '17 10:12 fabienbranchel

@fabienbranchel :

Could you send me a example of your package.json file, please?

Thanks a lot.

luizptm avatar Feb 07 '18 16:02 luizptm

@luizptm :

{
  "name": "test",
  "version": "1.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --aot",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.1.0",
    "@angular/cdk": "^5.0.0",
    "@angular/common": "^5.1.0",
    "@angular/compiler": "^5.1.0",
    "@angular/core": "^5.1.0",
    "@angular/forms": "^5.1.0",
    "@angular/http": "^5.1.0",
    "@angular/material": "^5.0.0",
    "@angular/platform-browser": "^5.1.0",
    "@angular/platform-browser-dynamic": "^5.1.0",
    "@angular/router": "^5.1.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.6",
    "@angular/compiler-cli": "^5.1.0",
    "@angular/language-service": "^5.1.0",
    "@angular/service-worker": "^5.1.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~4.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "2.4.2"
  }
}

fabienbranchel avatar Feb 08 '18 09:02 fabienbranchel

Thanks, @fabienbranchel. I am still having this issue. I changed the angular dependencies to version 5 as above and it not worked. Could someone help me, please?

luizptm avatar Feb 08 '18 14:02 luizptm

@luizptm : have you tried with the exact same versions of all depencies as above ?

fabienbranchel avatar Feb 08 '18 14:02 fabienbranchel

Yes, I tried it and nothing happen. It shows the same error.

luizptm avatar Feb 08 '18 15:02 luizptm

I had the same problem a while ago, turned out it was a problem with my browser (chrome). I cleaned the cache and then it worked great.

Len0re avatar Feb 09 '18 17:02 Len0re

Hi Len0re,

I was using another browser (Maxthon) and I tried now on Chrome for the first time and I received the same error. The first generated file that was showed was style.ac1cb6d1ddd09746eac0.js.

Thanks for your help.

luizptm avatar Feb 09 '18 17:02 luizptm

I had the same kind of error in production only, on a NodeJS server... Turns out I just forgot to restart the server !

adrienlamotte avatar Feb 17 '18 12:02 adrienlamotte

Could you be more specific? How ca I do this?

Thanks for helping.

luizptm avatar Feb 17 '18 13:02 luizptm

@luizptm really can't tell you as it depend on your server... We use foreverjs, so to restart I use something like : forever restart myproject

adrienlamotte avatar Feb 17 '18 17:02 adrienlamotte

I'm getting the same problem showing up when I put a CDN in front of express...goes away when I invalidate the cache. Any reason this would pop up with the way a CDN stores/ distributes the files?

goelinsights avatar Feb 17 '18 22:02 goelinsights

Getting the same problem only sometimes though when loading production build in browser.

thenninger avatar May 03 '18 12:05 thenninger