aws-actions / setup-sam

Action to set up AWS SAM CLI and add it to the PATH
Apache License 2.0
151 stars 23 forks source link

Getting Esbuild Failed: Cannot find esbuild in the GitHub Actions #56

Closed rajansharma3097 closed 2 years ago

rajansharma3097 commented 2 years ago

Hi,

We are getting Esbuild Failed: Cannot find esbuild in the GitHub actions. Here is the full error message:

Starting Build inside a container Building codeuri: /home/runner/work/BillingService/BillingService/billing-service runtime: nodejs16.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['handlers/app.ts']}} architecture: x86_64 functions: KBAddAccountCall

Fetching public.ecr.aws/sam/build-nodejs16.x:latest-x86_64 Docker container image......................................................................................................................................................................................................................................................................................................................................................................................................... Mounting /home/runner/work/BillingService/BillingService/billing-service as /tmp/samcli/source:ro,delegated inside runtime container

Build Failed Running NodejsNpmEsbuildBuilder:CopySource Running NodejsNpmEsbuildBuilder:NpmInstall Running NodejsNpmEsbuildBuilder:EsbuildBundle Error: NodejsNpmEsbuildBuilder:EsbuildBundle - Esbuild Failed: Cannot find esbuild. esbuild must be installed on the host machine to use this feature. It is recommended to be installed on the PATH, but can also be included as a project dependency.

2 days back, everything was working fine, but now somehow build process broke.

Can anyone please help me to resolve this issue?

Thanks in advance!

michal-organek commented 2 years ago

I have the same issue. I ran again builds that succeed yesterday, and they failed.

- uses: aws-actions/setup-sam@v2
michal-organek commented 2 years ago

@rajansharma3097 for me helped to add esbuild manually:

      - uses: aws-actions/setup-sam@v2
      - name: Install ESBuild
        run: |
          npm install -g esbuild
rajansharma3097 commented 2 years ago

@michal-organek thanks for your response. But for me, the suggested change is not working. Following is our GitHub actions yml file:

on:
  push:
    branches:
      - 2022-Q3-07-13
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: "3.8"
      - uses: aws-actions/setup-sam@v2
      - name: Install ESBuild
        run: |
          npm install -g esbuild
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      # First Delete the Stack
      # - run: sam delete --no-prompts
      # Build inside Docker containers
      - run: sam build --use-container --beta-features

Can you please look into this and suggest if we need to change anything else?

michal-organek commented 2 years ago

As I can see I have pretty much the same code as you :thinking:.

rajansharma3097 commented 2 years ago

@michal-organek we need to move esbuild dependency from dev dependency to production dependency in the package.json file. With that change, everything is working again now.