duckduckgoes
duckduckgoes

Reputation: 67

npm ERR! Failed during build script on github actions

I have frontend app written in react. I need to deploy it on azure. Moreover i have to use github actions. During building i get this error:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-06-25T18_19_29_860Z-debug.log
Error: Process completed with exit code 1.

My .yml file looks:

name: Build and deploy Node.js app to Azure Web App - uj-ebiznes-front

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Set up Node.js version
      uses: actions/setup-node@v1
      with:
        node-version: '14.x'

    - name: npm install, build, and test
      run: |
        CI=false npm install
        CI=false npm run build --if-present
    
    - name: 'Deploy to Azure Web App'
      id: deploy-to-webapp
      uses: azure/webapps-deploy@v2
      with:
        app-name: 'app_name'
        slot-name: 'production'
        publish-profile: //there's my secret
        package: .

I have already changed line with run on:

run: |
        CI=false npm install
        CI=false npm run build --if-present

I found some questions on github issues and on stackOverflow where answers indicate on this line. But it didn't help me.

Please, could you help me? Best regards.

Upvotes: 2

Views: 1991

Answers (2)

Malhar Lumbhani
Malhar Lumbhani

Reputation: 11

I was also getting the same error while deploying my react app on azure static web app service.

The error occurs because your code may be having warnings that will fail your build. In your .yml file, add an env setting, and inside that, make CI: false like this:

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    env:
      CI: false
    steps:

Upvotes: 1

AjayKumarGhose
AjayKumarGhose

Reputation: 4933

For npm error:-

Try with Create a new file inside your(VS) project with .env Then inside the .env file write this following code and save it.

`SKIP_PREFLIGHT_CHECK=true

The above command will help you in resolving the npm error. After successfully create then try to start the npm and check. This can be work for your issue.

Or, For more information about configuring your node.js app to azure web app Refer this MS Doc.

Deploy the node.js app to App Service from your local Git repository to Azure. Click here.

Upvotes: 1

Related Questions