2

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!

4 Answers 4

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

NOT SUPPORTED: keyword "id", use "$id" for schema ID I am getting this err. when i run the command.
1

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

Comments

0

Check if you have build:ssr script in your package.json file

1 Comment

No, it's not there.
0

This error was at me when I was trying ng npm run dev:ssr not in forlder with my Angular project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.