Angular working fine on localy but not on github action

Discussão em 'Angular' iniciado por Esaïe Njongssi, Outubro 31, 2024.

  1. I'm currently working on an Angular project that builds successfully on my local machine using the command ng build --prod. However, when I try to run the same build process in GitHub Actions, it fails with errors.

    Here’s the relevant part of my GitHub Actions workflow YAML file:

    name: Node.js CI

    on:
    push:
    branches: [ "master" ]
    pull_request:
    branches: [ "master" ]

    jobs:
    build:
    runs-on: ubuntu-latest

    strategy:
    matrix:
    node-version: [18.19.x]

    steps:
    - uses: actions/checkout@v4
    with:
    fetch-depth: 0 # Fetch all history for accurate versioning

    - name: Use Node.js ${{ matrix.node-version }}
    uses: actions/setup-node@v4
    with:
    node-version: ${{ matrix.node-version }}
    cache: 'npm'
    cache-dependency-path: package.json

    - uses: actions/cache@v4
    with:
    path: ~/.npm
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
    ${{ runner.os }}-node-

    - run: npm install -g @angular/cli
    name: Install Angular CLI

    - run: npm install --legacy-peer-deps
    name: Install dependencies

    - run: ng build --prod
    name: Compile for production


    Issue Details:

    1. Node.js Version: I'm using Node.js version 18.19.x in my GitHub Actions workflow but i'm using version 15.14.x locally.
    2. Local Build Success: The command ng build --prod works perfectly on my local environment.
    3. Error Message: The build fails in GitHub Actions, but I haven’t been able to capture the exact error message. It seems related to dependency resolution.

    Questions:

    • Why does the build work locally but fail in GitHub Actions?
    • Are there specific configurations or environment variables I need to set in the CI environment?
    • Is there a recommended way to debug this issue?
    • Should I add additional logging or modify my workflow steps?
    • Are there any known compatibility issues with Angular CLI and Node.js versions that I should be aware of?

    Additional Context:

    I've ensured that all dependencies are correctly defined in package.json and package-lock.json.

    I am using npm install --legacy-peer-deps to handle potential peer dependency issues.

    Any guidance or suggestions would be greatly appreciated!

    Continue reading...

Compartilhe esta Página