Reputation: 1459
After I tried to upgrade my angular version(6 to 9), I found that the old version of angular universal could be successfully packaged, but could not run normally.
Old angular universal packaging command:
ng build --prod ; ng run [project name]:server ; npm run webpack:server
Some files will be created before this command works, but the steps are complicated and I have forgotten.
I try to solve problems in the process, but new problems keep appearing.
So I plan to try the new version of angular universal, but it seems that the two versions of angular universal conflict with each other.
I had a problem running the first command:
ng add @nguniversal/express-engine --clientProject [project name]
Error message:
Skipping installation: Package already installed
ERROR! server.ts already exists.
The Schematic workflow failed. See above.
My package.json:
"dependencies": {
"@angular-devkit/build-angular": "^0.803.23",
"@angular/animations": "^9.0.0-rc.10",
"@angular/cdk": "^7.3.7",
"@angular/common": "^9.0.0-rc.10",
"@angular/compiler": "^9.0.0-rc.10",
"@angular/core": "^9.0.0-rc.10",
"@angular/forms": "^9.0.0-rc.10",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^9.0.0-rc.10",
"@angular/platform-browser-dynamic": "^9.0.0-rc.10",
"@angular/platform-server": "^9.0.0-rc.10",
"@angular/router": "^9.0.0-rc.10",
"@nguniversal/express-engine": "^9.0.0-rc.1",
"@nguniversal/module-map-ngfactory-loader": "^7.1.1",
"@ngx-meta/core": "^7.0.0",
"@ngx-share/core": "^7.1.4",
"@types/gapi": "0.0.39",
"@types/jquery": "^3.3.31",
"core-js": "^2.6.10",
"csspin": "^1.1.4",
"express": "^4.17.1",
"intersection-observer": "^0.5.1",
"ng-lazyload-image": "^5.1.2",
"ng-recaptcha": "^4.3.0",
"ngx-cookie-service": "^2.2.0",
"ngx-facebook": "^2.4.0",
"ngx-infinite-scroll": "^6.0.1",
"npm": "^6.12.0",
"rxjs": "^6.5.4",
"zone.js": "^0.10.2"
},
"devDependencies": {
"@angular/cli": "~9.0.0-rc.10",
"@angular/compiler-cli": "^9.0.0-rc.10",
"@angular/language-service": "^9.0.0-rc.10",
"@types/google.analytics": "0.0.39",
"@types/jasmine": "^2.8.3",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^8.10.54",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.13.1",
"protractor": "~5.3.0",
"ts-loader": "^5.4.5",
"ts-node": "^5.0.1",
"tslint": "~5.9.1",
"typescript": "^3.6.4",
"webpack-cli": "^3.3
Upvotes: 1
Views: 1022
Reputation: 11
Follow This Link: reinstall angular universal after angular cli upgrade
Remove all of the following files
Remove the "server" configuration. Something like:
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
}
After that, you can just do
ng add @nguniversal/express-engine --clientProject [project name]
Upvotes: 1