pm2 not found on Azure App service with Node 14 runtime
Asked Answered
C

1

2

What I am trying to achieve is to deploy Angular 9 app to Azure App service with Linux OS (Windows does not suit me because Linux is cheaper) I created Linux web app with Node 14 runtime. After I deployed my app I see Azure default web page. I tried to resolve that as it is described here

Steps I did on Linux web app with Node 14 runtime:

  1. I added this

    pm2 serve /home/site/wwwroot --no-daemon --spa

to AppService->Configuration->General Settings->Startup Command

  1. Saved configuration and restarted App Service But got pm2 not found error.

  2. Connected to web app using ssh and have run

    npm install pm2 -g

  3. Restarted App Service but still getting pm2 not found.

The question is how to host Angular 9 on Linux app service with Node 14? Should I fix that pm2 not found or I can use some other approach (but still with Linux OS) to solve that?

Ciracirca answered 30/3, 2021 at 12:33 Comment(2)
Changing your stack to node 12LTS will solve your problem, using 14 LTS is currently not feasible.Philhellene
@JasonPan proposal to use "npx serve -s" with Node 14 LTS worked fine for me.Ciracirca
P
8

Newest

If you are not concerned about the release method, it is recommended that you execute ng build locally, and then drag and drop all the files in the <your project name> folder directly to wwwroot, or use FTP to upload. Then modify startup cmd with npx serve -s, it also can work.

enter image description here

Files in local.

enter image description here

Files in wwwroot on azure.

enter image description here

Previous

After testing, I think this should be a bug. If you must use node 14LTS, I suggest you raise a support ticket on portal for help.

Recurring problem:

  1. Create a linux node 14LTS web app.

  2. Create ng9 project, use vscode deploy and success. Open website and show us default page.

  3. Add startup cmd with pm2 serve /home/site/wwwroot --no-daemon --spa or pm2 serve /home/site/wwwroot/dist/<your project name> --no-daemon --spa , and all failed.

Try to solve:

  1. I change Major version in Stack settings, and the project runs normally.

enter image description here

Philhellene answered 31/3, 2021 at 2:49 Comment(4)
"npx serve -s" solved the problem. Thanks!Ciracirca
Solved the problem. Many Thanks.Palladian
No drag and drop was needed. Just using npx serve -s in Startup command was enough to fix it for me.Badlands
Dear, in my case I wrote: node dist/server/main.js (in my case was an ng universal app) Can help me to figure out, why ?Jolly

© 2022 - 2024 — McMap. All rights reserved.