locked
How to run Next.js / Node.js app? RRS feed

  • Question

  • I am trying to run a next.js app into App Service, but I have erros.. 

    I am sharing the log file:

    2020-04-22T00:34:21.255464356Z   _____                               
    2020-04-22T00:34:21.255499558Z   /  _  \ __________ _________   ____  
    2020-04-22T00:34:21.255509058Z  /  /_\  \___   /  |  \_  __ \_/ __ \ 
    2020-04-22T00:34:21.255516958Z /    |    \/    /|  |  /|  | \/\  ___/ 
    2020-04-22T00:34:21.255524159Z \____|__  /_____ \____/ |__|    \___  >
    2020-04-22T00:34:21.255531859Z         \/      \/                  \/ 
    2020-04-22T00:34:21.255539159Z A P P   S E R V I C E   O N   L I N U X
    2020-04-22T00:34:21.255546660Z 
    2020-04-22T00:34:21.255553860Z Documentation: http://aka.ms/webapp-linux
    2020-04-22T00:34:21.255560560Z NodeJS quickstart: https://aka.ms/node-qs
    2020-04-22T00:34:21.255567461Z NodeJS Version : v10.10.0
    2020-04-22T00:34:21.255583761Z Note: Any data outside '/home' is not persisted
    2020-04-22T00:34:21.255591362Z 
    2020-04-22T00:34:21.561668123Z Oryx Version: 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
    2020-04-22T00:34:21.561735226Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
    2020-04-22T00:34:21.561749126Z Could not find operation ID in manifest. Generating an operation id...
    2020-04-22T00:34:21.561805929Z Build Operation ID: ab1c6476-5558-4c7f-89c7-fba613ec0b85
    2020-04-22T00:34:23.470082079Z Writing output script to '/opt/startup/startup.sh'
    2020-04-22T00:34:24.241158743Z Running #!/bin/sh
    2020-04-22T00:34:24.241898776Z 
    2020-04-22T00:34:24.241917477Z # Enter the source directory to make sure the script runs where the user expects
    2020-04-22T00:34:24.241927377Z cd "/home/site/wwwroot"
    2020-04-22T00:34:24.241935477Z 
    2020-04-22T00:34:24.243476246Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
    2020-04-22T00:34:24.243494846Z if [ -z "$PORT" ]; then
    2020-04-22T00:34:24.244254680Z 		export PORT=8080
    2020-04-22T00:34:24.244691999Z fi
    2020-04-22T00:34:24.244709100Z 
    2020-04-22T00:34:24.245363029Z PATH="$PATH:/home/site/wwwroot" yarn pwd
    2020-04-22T00:34:28.929303955Z yarn run v1.17.3
    2020-04-22T00:34:29.095127982Z $ yarn start
    2020-04-22T00:34:31.078725133Z $ next start
    2020-04-22T00:34:31.152186534Z /home/site/wwwroot/node_modules/.bin/next: 1: /home/site/wwwroot/node_modules/.bin/next: ../next/dist/bin/next: not found
    2020-04-22T00:34:31.196787678Z error Command failed with exit code 127.
    2020-04-22T00:34:31.197903427Z info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    2020-04-22T00:34:31.281339863Z error Command failed with exit code 127.
    2020-04-22T00:34:31.282599218Z info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    
    
    2020-04-22 00:34:32.301 ERROR - Container nextjs-dynamic-azure-example_0_24c48d5c for site nextjs-dynamic-azure-example has exited, failing site start
    2020-04-22 00:34:32.302 INFO  - Initiating warmup request to container nextjs-dynamic-azure-example_0_24c48d5c_middleware for site nextjs-dynamic-azure-example
    
    2020-04-22 00:34:35.788 INFO  - Container nextjs-dynamic-azure-example_0_24c48d5c_middleware for site nextjs-dynamic-azure-example initialized successfully and is ready to serve requests.
    2020-04-22 00:34:35.816 ERROR - Container nextjs-dynamic-azure-example_0_24c48d5c didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
    2020-04-22 00:34:35.838 INFO  - Stoping site nextjs-dynamic-azure-example because it failed during startup.
    2020-04-22T00:36:06  No new trace in the past 1 min(s).
    2020-04-22T00:37:06  No new trace in the past 2 min(s).
    2020-04-22T00:38:06  No new trace in the past 3 min(s).
    2020-04-22T00:39:06  No new trace in the past 4 min(s).
    I have all files.. include '/node_modules/.bin/next' and '.next'.

    Wednesday, April 22, 2020 1:08 AM

All replies

  • Thanks for asking question! As mentioned in the article your container must respond to an HTTP ping. As there is certain amount of time for your container to start before, we consider it be a failed start. In order for us to consider a container to be successfully started, the container must start, and it must respond to an HTTP ping. To elaborate on this the default time is 230 sec but we can configure the limit up to a 1800 sec by adding an app setting called WEBSITES_CONTAINER_START_TIME_LIMIT and set it to the number of seconds would like to wait for the container to start (up to a maximum of 1800 sec).

    Also check container logs: If "docker run" command is run and there are not any error messages here. Just double check on Node.js engine is listening on port you are using.

    You need to EXPOSE instruction in your Dockerfile to expose the port.

    In case your container listens to a port other than port 80. You may configure your app to route requests to that port.

    You may refer to below links for details on this: 

    https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-faq#custom-containers

    https://docs.microsoft.com/en-gb/archive/blogs/waws/things-you-should-know-web-apps-and-linux#troubleshooting

    -----------------------------------------------------------------------------------------------------------------------------------------

    We're migrating from MSDN to Microsoft Q&A as our new forums and Azure App Service has already made the move!  In future, you can ask and look for the discussion for Azure App Service related questions here:   https://docs.microsoft.com/answers/topics/azure-webapps.html

    We are actively working to onboard remaining Azure services on Microsoft Q&A. We will make a public announcement once complete. Want to Learn more about new platform: Microsoft Q&A Getting Started


    Wednesday, April 22, 2020 7:44 AM
  • It was two things:

    - The script "next start" didn't work, so I changed to "/home/site/wwwroot/node_modules/next/dist/bin/next start"
    - I changed the port, as you said, to 80.

    And now it's working =)

    Thanks!

    Wednesday, April 22, 2020 12:53 PM
  • Glad to hear that you got it working. If the above answer was helpful, kindly do ‘Mark as answer” and/or ‘Vote as helpful’ the post for benefiting the other users with a similar issue.

    Wednesday, April 22, 2020 6:19 PM