Closed aleguern closed 1 year ago
Per the error message:
esbuild must be installed on the host machine to use this feature.
Do you have eslint
installed on the machine running the workflow?
Yes I did install it with npm i -g esbuild
, is there a different way to do this ?
So to be clear, esbuild
is installed in the GitHub Actions environment (not only on development machine), and is in the PATH
(i.e. you can use esbuild
and it'll call the executable correctly)?
I run npm i -g esbuild
and then run esbuild --version
it displays the correct version 0.18.6
Can you include the relevant parts of your GitHub workflow? Specifically, where eslint and SAM CLI is installed, and where SAM CLI is called.
jobs:
build-and-package:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm i -g esbuild
- run: esbuild --version
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- name: Build resources
run: sam build --template ${SAM_TEMPLATE} --use-container
With --use-container
the project will be built in a container, so whatever is installed on the host won't be available in it. It should work if you make esbuild
a project dependency, so that it's picked up in the container as well.
Thanks for your advice, I’m not sure what I’m supposed to do, could you tell me how to do this ?
Try adding it as a dependency to your package.json
.
That’s already what I did and not working, I tried adding it to dependencies and devDependencies.
Interesting; can you share your package.json
? And project structure as well if possible (to ensure it's picking up the correct package.json
). We haven't been able to reproduce the issue.
Adding some extra context here. I was unable to reproduce this issue in GitHub actions. My setup looks like this and runs successfully
├── README.md
├── events
│ └── event.json
├── hello-world
│ ├── app.ts
│ ├── jest.config.ts
│ ├── package.json
│ ├── tests
│ │ └── unit
│ │ └── test-handler.test.ts
│ └── tsconfig.json
├── samconfig.toml
└── template.yaml
package.json
{
"name": "hello_world",
"version": "1.0.0",
"description": "hello world sample for NodeJS",
"main": "app.js",
...
},
"dependencies": {
"esbuild": "^0.14.14"
},
"devDependencies": {
...
}
}
and the workflow
name: Build
on: push
jobs:
build:
name: Build esbuild project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- run: sam build -u
I noticed you also specify the template. Can you confirm the template flag is pointing to the correct file?
I found the bug I'm sorry, it seems I forgot to install esbuild dependency at the lambda level, it was only installed at the root lebel.
No worries! Thanks for the update; good you found the issue.
Hello,
I am encountering an error while using Sam build on GitHub Actions with the AWS-actions/setup-sam. Strangely, the build process works perfectly fine on my local machine using Sam build. However, when the same build process is executed on GitHub Actions, I receive the following error:
"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."
I have double-checked that esbuild is installed on my local machine and even included it as a project dependency, which allows me to perform successful builds locally. However, the error only occurs within the GitHub Actions environment.
I kindly request your assistance and guidance in troubleshooting this perplexing issue. If anyone has encountered a similar situation or possesses insights into potential solutions, I would greatly appreciate your input.
Thank you for your support.