2
votes

Am Using the angular universal 1.0.0-alpha.universal.3

I have created the new app using the angular universal cli.

ung new test-app --universal

package.json

{
  "name": "test-app",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ung serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ung test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.2.3",
    "@angular/compiler": "2.2.3",
    "@angular/core": "2.2.3",
    "@angular/forms": "2.2.3",
    "@angular/http": "2.2.3",
    "@angular/platform-browser": "^2.2.3",
    "@angular/platform-browser-dynamic": "2.2.3",
    "@angular/platform-server": "^2.2.3",
    "@angular/router": "3.2.3",
    "@ngx-universal/state-transfer": "^4.0.1",
    "angular2-express-engine": "2.1.0-rc.1",
    "angular2-flash-messages": "^1.0.8",
    "angular2-jwt": "^0.2.3",
    "angular2-platform-node": "2.1.0-rc.1",
    "angular2-universal": "2.1.0-rc.1",
    "angular2-universal-polyfills": "2.1.0-rc.1",
    "bcryptjs": "^2.4.3",
    "bootstrap": "^3.3.7",
    "compression": "1.6.2",
    "core-js": "^2.4.1",
    "cors": "^2.8.4",
    "express": "^4.14.0",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "jsonwebtoken": "^8.1.0",
    "mongoose": "^4.13.1",
    "passport": "^0.4.0",
    "passport-jwt": "^3.0.0",
    "passport-local": "^1.0.0",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@angular/compiler-cli": "2.2.3",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "@types/body-parser": "0.0.29",
    "@types/compression": "0.0.29",
    "@types/cookie-parser": "^1.3.29",
    "@types/express": "^4.0.29",
    "@types/express-serve-static-core": "^4.0.29",
    "@types/mime": "0.0.28",
    "@types/serve-static": "^1.7.27",
    "universal-cli": "1.0.0-alpha.universal.3",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }
}

I would like to add the below browserModule on my app.browser.module.ts file

BrowserModule.withServerTransition({ appId: 'test-app' })

After adding this script am getting below error.

Uncaught Error: Module build failed: Error: E:/projects/Angular2/test-app/src/app/app.browser.module.ts (32,19): Property 'withServerTransition' does not exist on type 'typeof BrowserModule'.)
    at _checkDiagnostics (E:\projects\Angular2\test-app\node_modules\@ngtools\webpack\src\loader.js:115:15)
    at E:\projects\Angular2\test-app\node_modules\@ngtools\webpack\src\loader.js:140:17
    at 
    at _checkDiagnostics (E:\projects\Angular2\test-app\node_modules\@ngtools\webpack\src\loader.js:115:15)
    at E:\projects\Angular2\test-app\node_modules\@ngtools\webpack\src\loader.js:140:17
    at 
    at Object.433 (http://localhost:4200/client.bundle.js:83:7)
    at __webpack_require__ (http://localhost:4200/inline.bundle.js:53:30)
    at Object.334 (http://localhost:4200/client.bundle.js:29:82)
    at __webpack_require__ (http://localhost:4200/inline.bundle.js:53:30)
    at Object.624 (http://localhost:4200/client.bundle.js:171:18)
    at __webpack_require__ (http://localhost:4200/inline.bundle.js:53:30)
    at webpackJsonpCallback (http://localhost:4200/inline.bundle.js:24:23)
    at http://localhost:4200/client.bundle.js:1:1

link: https://github.com/angular/angular-cli/issues/8476

1
You should add more error log in your question. It can better help you. How to Asklwinkyawmyat

1 Answers

1
votes

I think WithServerTransition was added in angular 4. Upgrade to angular 4 or 5 if you are starting a new project

v2 docs https://v2.angular.io/docs/ts/latest/api/platform-browser/index/BrowserModule-class.html

v4 docs https://v4.angular.io/api/platform-browser/BrowserModule