2

I currently try to update from angular 5 to 6.rc0. I changed my package json to look like that:

{
  "name": "angular5to6",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "6.0.0-rc.0",
    "@angular/cdk": "6.0.0-beta.5",
    "@angular/common": "6.0.0-rc.0",
    "@angular/compiler": "6.0.0-rc.0",
    "@angular/core": "6.0.0-rc.0",
    "@angular/forms": "6.0.0-rc.0",
    "@angular/http": "6.0.0-rc.0",
    "@angular/material": "6.0.0-beta.5",
    "@angular/platform-browser": "6.0.0-rc.0",
    "@angular/platform-browser-dynamic": "6.0.0-rc.0",
    "@angular/router": "6.0.0-rc.0",
    "core-js": "2.5.3",
    "material-design-icons": "^3.0.1",
    "roboto-fontface": "^0.9.0",
    "rxjs": "^5.6.0-forward-compat.2",
    "zone.js": "0.8.20"
  },
  "devDependencies": {
    "@angular/cli": "6.0.0-beta.6",
    "@angular/compiler-cli": "6.0.0-rc.0",
    "@angular/language-service": "6.0.0-rc.0",
    "@types/autobahn": "^0.9.38",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "8.10.0",
    "autobahn": "^18.3.1",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "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": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "2.7.2"
  }
}

I updated all dependencies and ng build works after updating to node 8.10.0 when I open my browser and try to run the build I get the following issue:

index.js:43 Uncaught ReferenceError: global is not defined
at Object.../node_modules/buffer/index.js (index.js:43)
at __webpack_require__ (bootstrap:74)
at Object.../node_modules/safe-buffer/index.js (index.js:2)
at __webpack_require__ (bootstrap:74)
at Object.../node_modules/msgpack5/index.js (index.js:3)
at __webpack_require__ (bootstrap:74)
at Object.../node_modules/autobahn/lib/autobahn.js (autobahn.js:22)
at __webpack_require__ (bootstrap:74)
at Object.../node_modules/autobahn/index.js (index.js:14)
at __webpack_require__ (bootstrap:74)

For some reason it seems that webpack does not render everything into browser compatible code.

[UPDATE]

It seems like a couple of external packages break. I'm just not sure why. They have nothing to do with angular!? In this case it is the msgpack5 package.

1 Answers1

1

I found the issue causing the problem. I opened a new issue to the angular/cli project. I had to downgrade from

"@angular/cli": "6.0.0-beta.6"

to

"@angular/cli": "1.7.3"

Thats it!

[UPDATE] The update to the latest CLI/angular 6 with autobahn is possible by using a polyfill

(window as any).global = window;
(window as any).process = window;
(window as any).Buffer = window;
(window as any).process.browser = true;
(window as any).process.version = '';
(window as any).process.versions = {node: false};