Angular, NodeJS, Web Development

Angular 6 – Configure Angular Universal with pm2

Angular Universal allows Angular apps to be run in both the server and in the browser. Before, I used the plain Express server to serve the static Angular application and I used the pm2 tool to manage the server process. With Angular Universal, the same is used to make it work with pm2.

Starting the process

The usual way to start the Angular Universal web server is this:

# yarn
yarn run serve:ssr
# npm
npm run serve:ssr

With pm2, you can’t run the yarn command just like that. Instead, look at the package.json and find the actual command executed. This is the command that I’ve found for the serve:ssr command:

node start dist/server

Here is the pm2 compatible version:

pm2 start dist/server

That’s it! Will post the full details about my Angular Universal experience in the next posts.

2 thoughts on “Angular 6 – Configure Angular Universal with pm2”

  1. I have moved dist folder to my ec2 instance also create port number in custom tcp but checking my url it shows folder lists in browser..

Leave a reply

Your email address will not be published. Required fields are marked *