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.

This entry was posted in Angular, NodeJS, Web Development and tagged , , . Bookmark the permalink.

Related Posts

Leave a Reply

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