Reputation: 1087
I created simple Angular app and then tried to create a server-side app using Angular Universal. However, in every single tutorial the first step is to run npm run build:ssr
which in my case throws an error:
npm ERR! missing script: build:ssr
I must be missing something obvious but I can't figure out what. I checked StackOverflow for this issue, there is one, however, without accepted answer. One hint would be to check the Angular/Angular Universal version, but these seems to be aligned for me:
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/http": "^7.2.14",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/platform-server": "^7.2.14",
"@angular/router": "~7.2.0",
"@ng-toolkit/universal": "^7.1.2",
"@nguniversal/common": "^7.1.1",
"@nguniversal/express-engine": "^7.1.1",
"@nguniversal/module-map-ngfactory-loader": "^7.1.1",
Any help would be much appreciated. Thanks!
Upvotes: 2
Views: 4426
Reputation: 1583
This error was at me when I was trying ng npm run dev:ssr not in forlder with my Angular project.
Upvotes: 0
Reputation: 31
this issue is occurring probably because you might not have run the @nguniversal express-engine command :
ng add @nguniversal/express-engine --clientProject (Project Name)
Project name can be found in angular.json file under projects attribute.
This will generate server module and build:ssr
It should work after running this hopefully.
Upvotes: 2
Reputation: 405
For better understanding how angular universal should be configured properly you can take a look on official sample universal's starter repo https://github.com/angular/universal-starter
Here you have also example how to setup package.json properly https://github.com/angular/universal-starter/blob/master/package.json
Upvotes: 1
Reputation: 736
Check if you have build:ssr script in your package.json file
Upvotes: 0