-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Problem
I am referring to the section "Local testing" in Lesson 4. When I tried to run the command:
sam build beta-features
I encountered the following error:
Build Failed
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.
Analysis
The error indicates that the esbuild package is not found. This typically happens because esbuild is listed under devDependencies in the package.json, which are not installed in some environments, particularly in production or when running certain build tools.
Fix
To resolve this issue, I had to move the esbuild package from devDependencies to dependencies in the /backend/package.json file. Here is the modified section:
...
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.95.0",
"@aws-sdk/client-sqs": "^3.95.0",
"@aws-sdk/lib-dynamodb": "^3.95.0",
"nodemailer": "^6.7.5",
"esbuild": "^0.14.14"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.92",
"@types/node": "^17.0.13",
"ts-node": "^10.4.0",
"typescript": "^4.6.4"
},
...Additional Note
- This solution was derived from a Stack Overflow post which suggested ensuring
esbuildis installed as a dependency rather than a devDependency. - You could also install esbuild globally using
npm install -g esbuild
Metadata
Metadata
Assignees
Labels
No labels