Having issue with my linux web app (Node).

neutrolabs limited 0 Reputation points
2024-01-18T16:09:45.3433333+00:00

Keep getting application error when i try loading my app. when i performed deep analysis i found out that the container keep throwing this error. requireStack: [ '/home/site/wwwroot/node_modules/.bin/react-scripts' ]

Error: Cannot find module '../scripts/start'
2024-01-16T00:00:50.836917218Z Require stack:
2024-01-16T00:00:50.836920419Z - /home/site/wwwroot/node_modules/.bin/react-scripts
2024-01-16T00:00:50.836923819Z     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
2024-01-16T00:00:50.836927319Z     at Function.resolve (node:internal/modules/cjs/helpers:127:19)
2024-01-16T00:00:50.836931419Z     at Object.<anonymous> (/home/site/wwwroot/node_modules/.bin/react-scripts:31:23)
2024-01-16T00:00:50.836935619Z     at Module._compile (node:internal/modules/cjs/loader:1256:14)
2024-01-16T00:00:50.836940019Z     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
2024-01-16T00:00:50.836944019Z     at Module.load (node:internal/modules/cjs/loader:1119:32)
2024-01-16T00:00:50.836947419Z     at Module._load (node:internal/modules/cjs/loader:960:12)
2024-01-16T00:00:50.836950919Z     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2024-01-16T00:00:50.836955219Z     at node:internal/main/run_main_module:23:47 {
2024-01-16T00:00:50.836958719Z   code: 'MODULE_NOT_FOUND',
2024-01-16T00:00:50.836961919Z   requireStack: [ '/home/site/wwwroot/node_modules/.bin/react-scripts' ]
2024-01-16T00:00:50.836965619Z }
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
966 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Grmacjon-MSFT 18,451 Reputation points
    2024-01-19T00:30:00.2033333+00:00

    Hello @neutrolabs limited we are sorry to hear you're having this issue. can you please share how you deployed your Linux web app?

    The error message you’re seeing, “Error: Cannot find module ‘…/scripts/start’”, typically occurs when Node.js can’t find the module it’s trying to require. In this case, it seems like it’s unable to find the start script in your react-scripts package. Is the start script in your package.json file correctly pointing to the start script in package?

    Sometimes, this issue can be resolved by deleting your node_modules folder and your package-lock.json file, and then running npm install to reinstall your packages. Also, if you’re deploying your app to Azure, make sure that your startup command is correctly set in your App Service configuration

    For example, you might need to set the startup command to pm2 start <.js-file-or-PM2-file> --no-daemon---


    I hope this helps! Let me know if you have any other questions.

    -Grace


  2. Mohammad Yousuf 0 Reputation points
    2024-06-18T08:29:33.9166667+00:00

    Here is a workflow file that resolved my issue. don't forget to set "SCM_DO_BUILD_DURING_DEPLOYMENT = true" in web app environment variables on Azure:

    on:
      push:
        branches:
          - main
      workflow_dispatch:
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
          - uses: actions/checkout@v4
    
          - name: Set up Node.js version
            uses: actions/setup-node@v3
            with:
              node-version: '20.x'
    
          - name: Install dependencies
            run: npm install
    
          - name: Build the React app
            run: npm run build
    
          - name: Zip the build directory for deployment
            run: zip -r release.zip ./*
    
          - name: Upload build artifact
            uses: actions/upload-artifact@v3
            with:
              name: react-app
              path: release.zip
    
      deploy:
        runs-on: ubuntu-latest
        needs: build
        environment:
          name: 'Production'
          url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
        permissions:
          id-token: write
    
        steps:
          - name: Download build artifact
            uses: actions/download-artifact@v3
            with:
              name: react-app
    
          - name: Login to Azure
            uses: azure/login@v1
            with:
              client-id: ${{ secrets.AZUREAPPSERVICE_}}
              tenant-id: ${{ secrets.AZUREAPPSERVICE }}
              subscription-id: ${{ secrets.AZUREAPPSERVICE }}
    
          - name: Deploy to Azure Web App
            id: deploy-to-webapp
            uses: azure/webapps-deploy@v2
            with:
              app-name: 'web-app-name'
              slot-name: 'Production'
              package: release.zip
    
    0 comments No comments

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.