Closed paoptu023 closed 5 years ago
I see the same issue when using 0.15.0
@paoptu023 and @steventen This is currently by design. NPM will place node_modules
in the same folder as package.json
. Since you placed the package.json
not in the function folder, you will not get the node_modules
with your function directly. Based on feedback from the community (when we first built build), the recommendation was to place the manifest files (requirements.txt, package.json, pom.xml, etc) into the function folders. If you follow this practice (how all the init projects are setup), things will work as you expect.
With that said, the way forward is to move the package.json
file into the function directories (the CodeUri location).
Closing as this is working as expected.
Description
My project structure is laid out like this:
In the original template, I set the
CodeUri
toapp/
andHandler
tolambda.handler
.When I ran
sam build -m package.json
at the root directory, the generated .aws-sam/build folder is like this:The built template set
CodeUri
toHelloWorldFunction
, butHandler
is stilllambda.handler
. Then when I ransam local start-api
and visited http://127.0.0.1:3000/, it gave me the following error:Steps to reproduce
See above.
Observed result
Please provide command output with
--debug
flag set.Expected result
I'm not sure whether the current behavior is expected or not. It seems that
sam build
just copies the whole directory wherepackage.json
exists regardless of whatCodeUri
I specify in the template. I thinksam build
should packpackage.json
with theCodeUri
directory and output the built template accordingly.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 0.14.2