简体   繁体   中英

Error running nextjs with PM2 on Azure App Service on Linux

The pipelines and releases seem to work finely as they get the artifact deployed on the app service or so it seems as the output error happens on start of the PM2 process.

I haven't found anything on this error on google, and don't know if there is a way to update PM2 on the app service machine as PM2 itself suggests.

These are the logs.

Error message

在此处输入图像描述

summary image

在此处输入图像描述

I was expecting the app to work and no longer show an application error as I fixed both build and release pipelines.

This is a picture of the important bit of info of the error as its really long

Check the below steps to run nextjs with PM2 .

  • First create a nextJS app .

Run npm run dev command to run the app in development.

  • Deploy the app to Azure Linux App Service.

Open the SSH of the Azure App Service to run the PM2 commands.

  • We can open directly with the below URL. Path to SSH - https://YourDeployedAppName.scm.azurewebsites.net/

在此处输入图像描述

OR

  • Navigate to the deployed Azure Linux App => Advanced Tools => Go => SSH .

在此处输入图像描述

Run the below command to install PM2 .

npm install pm2 -g

在此处输入图像描述

在此处输入图像描述

Thanks @ Azure OSS Developer Support for the commands.

  • In Configuration section => General Settings add the Startup command.
 pm2 start site/root/index.js --name mynpmnextapp

Your path may differ for the index.js file.

My app entry point is index.js .For some apps it can be server.js .Change it according to your app.

在此处输入图像描述

cannot find module `../build/output/log'

Make sure you are not running the PM2 with the output folder. As mentioned above it has to be the entry point either server.js or index.js based on your code files.

don't know if there is a way to update PM2 on the app service

In the KUDU Console use npm install pm2@latest -g to update the PM2.

References taken from MSDoc and npmjs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM