-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAM build doesn't install local file dependency #3854
Comments
@AlDawoode Thanks for the issue. This is a current limitation in how the npm builder works. We have an open issue on this in our AWS Lambda Builders module/repo: aws/aws-lambda-builders#222. Here is the design the describes the implementation of the builder: https://github.com/aws/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/nodejs_npm/DESIGN.md The challenge is two fold:
The way around this is to use the |
Resolving this issue since there is already one in Lambda Builders repository: aws/aws-lambda-builders#222 Please feel free to comment on that issue. |
Any update, it is still not working |
Yes it's still not working. the workaround was made by my team is to use esbuild to bundle all dependencies. |
I'm programmatically copying my echo
echo Copying package.json to dependencies folder
cp -v package.json ./dependencies/nodejs
echo
echo Installing dependencies
cd dependencies
cd nodejs
npm i
cd ..
cd ..
echo
echo "Invoking function ${FUNCTION_NAME} with event ${EVENT_NAME}"
sam local invoke ${FUNCTION_NAME} --event src/events/${EVENT_NAME}.json --profile DEV --env-vars .env.json --region eu-west-1 --template template-personal.yaml |
We've been working on building in source feature, which should resolve local dependencies. See: #4571 |
Description:
I have a SAM template that create a lambda function (Node js project).
As i understand when i run the command "SAM build", SAM read the SAM-template and start to copy all files needed to the folder called ".aws-sam" and it will run npm install at the end...
The issue happen when i declare a local file dependency in my package.json.
SAM not able to install the local file dependency, because the file path for the local dependency is not right anymore (because SAM copied the files to another location (to .aws-sam folder)
In my Lambda function folder there is a package.json file that contain local file dependencies :
{
"name": "import-temp-tables-to-db",
"version": "1.0.0",
"description": "",
"main": "none.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "UNLICENSED",
"dependencies": {
"shared": "file:../../shared",
"api-utilities": "file:../../../shared/api-utilities",
"debug": "^4.3.3"
}
}
If i don't use sam build at all, and instead use npm install, then the local file dependencies appear under node_module (because the path is right).
sam --version
: SAM CLI, version 1.41.0The text was updated successfully, but these errors were encountered: