-
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
npm link causes sam local to error #756
Comments
Same exact problem for some local developments and dependencies loaded via a local "file:" path which result in a symlink too. |
@paulsson Thanks for submitting the issue. This sounds like something that |
this will be resolved with the new builder. for now, you can use |
@jfuss the post |
@ericallam It does support hot-reloading but you need to build in another terminal window. We will eventually introduce a Symlinks and docker do not play well together: https://stackoverflow.com/questions/38485607/mount-host-directory-with-a-symbolic-link-inside-in-docker-container. So yes we understand this will help, but if docker doesn't support symlinks, it hard for us to support it through mounting of the code. Therefore need some other process (I am thinking build) to help solve that. |
@jfuss ah I didn't know about the plan for |
I am also building an application with Node that's constructed in much the same way. I am using lerna to manage symlinks from packages outside of the main handlers. This is juggleable now by releasing minor patch versions that my handlers can consume but, would love the freedom to be able to work with the symlinks. Also totally understand that docker and symlinks don't play super nice together. Excited to see if this build watch for the node 8.10 runtime fixes this issue. Thank you all. |
@paulsson We have released build support for |
@jfuss this sounds great! I will be testing this out today and get back to you with any questions or feedback. Thanks! |
@jfuss does this work when using 'sam local start-api' for simulating api-gateway locally? I see the output of 'sam build' does not list 'sam local start-api' as a next command:
Do I have to run 'sam local start-api' from the newly created .aws-sam/build directory where the new |
@paulsson symlinks aren't supported in sam build for node yet, I plan to work on it once all the pending PRs for the node builder get merged to avoid conflicts. |
@gojko Any sense of when symlinks will be supported in sam build for node? This will be awesome! |
+1 - symlinks, or at least, npm packages with "file://../another_folder/" would be a massive help for code-reuse. |
@abbottdev we have the code ready, just need to add a few more tests. should be within the next few days hopefully |
Thanks all. Exited to give it a whirl |
just a quick update on this, the code is ready, but it seems that it's not likely going to be merged, so you won't be able to use SAM with local deps (aws/aws-lambda-builders#106). My suggestion is to use |
@gojko Bummer. But thanks very much for the update! |
This is something we want to support but we have a challenge due to how we currently build functions, which is what is holding this up not because we don't want it merged. @thesriram Made a comment on the PR: aws/aws-lambda-builders#106 (comment) but will rephrase here. Currently SAM CLI mounts code into the container for each function. For the local dependency case (in the container), there is no way to build with local dependencies unless the code is mounted. To support this we need to change how we mount code into the container, most likely mount the project instead and execute |
in my case, i'm using |
+1 I'm testing git submodule and it's working well, but npm is better to this use case. |
+1 |
Hi! First off, I love the vscode integration. Launching a debugger from within the code file by clicking an annotation is genius. I'd love to start using sam, but without being able to set a breakpoint in vscode and step into a local dependency's symlinked (via "file:" and npm link) code, I just can't start using it for everyday development work. I'm hoping there are others out there like me who are writing lambdas that depend on local libraries, and want to set a breakpoint in a dependent library while debugging things? It seems like a common real-world node development thing. (Especially with the introduction of yarn workspaces, which takes this to the next level.)
It's been suggested to package the dependencies up on build. This is a little iffy, because now the code that you are debugging is not the real code in your working directory. I've been here, and you wind up flipping between files a lot, and accidentally making changes to the ephemeral file and losing them on the next build. You should be able to make changes to the file that it's showing you while you debug. It's not a great developer experience. Support for this would be so amazing. It really was a "so close!" moment for me. Any others out there struggling with this? Say heyyy |
My current solution is to include the package in
This commands
This ensures the dependencies of the common package are properly installed. Problems with this approach:
|
It looks like this PR will help: Will it fix the issue or do you need other features to work with local packages? |
@gojko I have tried claudia pack, but unfortunately is not working either with symlink, I have inspected the zip but the linked module is not present =( |
That's happening because the default esbuild pipeline in build phase. Of course, when sam clit run: |
Hello! I'm using sam local to rapidly develop and test nodejs lambda functions.
SAM version: SAM CLI, version 0.6.1
MacOS 10.13.6
I have common code in separate node modules that I am trying to use 'npm link' with to create symlinks for in my lambda functions node_modules directory. This would be a great way to allow editing the common code in directories outside of my lambda function directories and just have those changes immediately available to my lambda functions where they are linked in the lamdba function node_modules directories. Otherwise, every time I change the common code I would have to go through extra steps to copy it to every lambda functions node_modules directory for the lambdas that need to use that common code.
The advantages of this is explained very well here:
https://forums.aws.amazon.com/thread.jspa?threadID=214756#jive-message-671727
and here:
https://stackoverflow.com/questions/33511652/including-local-dependencies-in-deployment-to-lambda
I can see that my symlinks are created properly and I can 'ls' the symlink to see that it lists the expected files back in the linked directory. However, when I run my code and try to test when using these symlinks I get:
If I copy my common node modules directly into my lambda function node_modules directories everything works perfectly.
Any suggestions? Does it sound like I am doing something wrong? Is this a known issue?
If I can copy my node module directly into my lamda node_modules directory rather than using a symlink it seems like there might be some issue preventing this. Having this capability would greatly help developing node lambda functions to be much faster.
Thanks!
The text was updated successfully, but these errors were encountered: