-
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 does not recognise local nodejs projects outside CodeUri #2064
Comments
@sriram-mv , sorry, I'm a bit new to github. Could you please explain what the added "type/feature" means? Does that mean this bug is being looked at? |
Here is a work around: I did manage to "force" the creation of the Here is my new file:
Then, when It is dirty... but it allows to deploy for now. |
This work around work only when the name of the directory is alphanumeric. |
Here is my work around. It is not pretty but it works. First, use Next, set the My folders look like this:
So I start by going into the Now a |
Here's my work around. Simply put - copy the dependency project into the current root. My project has three parts - frontend, backend (SAM) and "proj-common", common artifacts for both front and backend. I first put the dependency in package.json "dependencies" as "file:../proj-commons", pointing to the local folder. This works for the IDE, but sam build fails. The reason is SAM build in a container. In that container the mapped dir cannot access proj-commons. Check I tried to put "../proj-commons" in "files" of "package.json" and it does not work. I tried to symbol link "../proj-commons" to a folder under the root, and refer to the folder in both "dependencies" and "files", it does not work. So the final work around is - in my build script, first copy "../proj-commons" into a directory under the SAM project root, and also put it inside "files" in "project.json". Here's how my package.json looks like. Note the build script. "dependencies": {
"aws-sdk": "^2.437.0",
"proj-commons": "file:./.dependency_by_copy/proj-commons"
},
"files": [
"built/",
".dependency_by_copy/"
],
....
"scripts": {
"build": ". ./env.sh; rm -fr ./.dependency_by_copy; mkdir .dependency_by_copy; cp -r ../proj-commons ./.dependency_by_copy; tsc; sam build; announce \"Project Built\"",
|
I am trying to add some shared code to a layer but I am getting this error as well. The Before :
After :
You can find the full example here : https://github.com/fbn-roussel/aws-sam-typescript-webpack-backend/blob/main/layers/application-layer/package.json Native support of local path dependency would be greatly appreciated :) |
We are currently reviewing a PR that should address this issue: |
hi, |
@cBiscuitSurprise thank you for the hard work building this critical functionality! 🙏 @mgrandis I and probably the entire AWS SAM community are wondering if there is any progress on this PR since Feb 26? are there any better workarounds we should be aware of? Is there any way we can help test this so it will move forward? Thanks! |
If you are willing to try CDK, NodejsFunction with esbuild works for me pretty well. See https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html#local-bundling https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html#configuring-esbuild |
We've been limping along using 8c33ad6 custom-installed into our build environments. As much as I'd love to see @mgrandis and I's work merged into the product, my team has been slowly making proper JS packages out of all the instances where we're using this feature. I'm happy to continue helping get this across the finish line. On the other hand, we can live without it (once we're fully converted to proper JS packages). |
Thanks, @bingtimren & @cBiscuitSurprise, for the replies! Sadly we are not using CDK for various reasons.
With that, do you mean a package that is published to the npm repository? Unfortunately, our internal library is private and needs to be resolved by our build system and other dev machines. Is there a way to get around this? My goal is to share a library between all of my lambda functions. I honestly don't have a preference on how it's happening. |
@eladg Yep, we're slowly isolating our modules as needed into packages which we publish to our private npm package registry (we use GitLab's package registry -- it can be free, even for private registries) and then just installing them like anything else. |
@cBiscuitSurprise that idea is quite the last option we should consider in our case. local modules are standard in npm so it should just work. the impact in introducing new registries for npm packages is quite big - credentials, build pipelines, local build etc. But at least it is a valid option. what we have done so far, is to create a symlink for our local packages into the aws build dir. at least it is working, but still not a very good option, because there is no optimization within the package steps. and you have to put this peace of linking code to each function.
with that kind of workaround we can build and package using sam build on local machine and with cloudbuild. In the end we need the support for local modules. :-) |
Closing so that we can track in the above issue ( |
|
|
|
Description
I have 2 Node.js projects:
CommonT
andProfile
.Profile
has a local dependency onCommonT
.When running the
sam build -t template.yaml --debug
command, it fails with the following error:Here is the project structure:
Here is the Profile/package.json:
Here is the CommonT/package.json:
Here is my template.yaml:
This is an error I was facing with
sam --version: 0.11.0
that disapeared when upgrading tosam --version: 0.52.0
using homebrew. I am currently moving CICD tool and I installed the samesam --version: 0.52.0
using pip3 as I cannot install homebrew on my CICD platform. So here it is:ERR! code ENOLOCAL
ERR! code ENOLOCAL
Steps to reproduce
Observed result
Expected result
When manually running the builds/tests with npm, everything compiles and run properly. I expect the same behavour to happen with
sam build
.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Ubuntu 18.04.4 LTS
sam --version
: 0.52.0The text was updated successfully, but these errors were encountered: