[Music]
hello I'm Kim a cloud support engineer
here at the ADA best office in Dallas
sometimes customers ask me how to build
a nativist laminate deployment package
for nodejs I tell them that when you
create an ad of a slanted function in
nodejs a common area you might get
during invocation is cannot find module
this is usually due to a deployment
package not having the correct folder
structure for tool and the service to
load your modules and libraries today
I'm going to walk you through how to
create build and check your node.js
deployment package for your node base
land the function let's get started
first you need to make sure that you
install your required dependencies to
your local project folder now you can
see I'm already logged in to my terminal
change over to your project folder
as you can see I simply have my function
code right there
this will be the floor that can change
your no project source files it should
be the root level of your source files
where your function handler node file
resides now if you've been testing your
function on your local system by
directly executing it you might not have
seen any problems but if you attempted
to upload your function code to a deus
lambda without the required dependencies
you willing to various cannot find
module errors this is because the base
container in lambda does not include any
third-party modules except for the age
of s JavaScript SDK to install your
modules locally you will need to use NPM
to install them to your local project
folder you can use the following command
to install a package again you use the
following command to install your
package here I've copied the command
already but you can find an example of
this command in the attached knowledge
center article you can use the command
NPM install and the package name that
you need in this case I'm installing the
ATS SDK for JavaScript
once npm completes you'll have the ATF's
sdk for javascript repeat this for all
modules required by your land of
function but remember there's a 250
megabyte limit on your function sighs
when unzipped only include the libraries
you need for your function to work also
note that a device l'anima does include
the a DMS JavaScript SDK libraries as
part of the base container configuration
if you need to use a different version
or more recent version of the library
you include a local copy as well after
you've added all of your required
modules it's time to zip your functions
the land of service expects your zip
file to have a specific folder structure
in which your functions handler code
file exists in the root of your zip
package and all other dependencies exist
relative to the function of the file in
the root first I'll do this with
commands are compatible in Mac or Linux
to zip the file we're going to run a
recursive zip command and place the zip
file in the parent directory of the
project folder again i've copied the
command from my clipboard but you can
find an example of this command in the
attached knowledge center article run
the command zip - our in this case dot
dot slash my underscore function dot zip
and a dot at the end to break this down
the - are tells the zip to recursively
include all files the dot dot forward
slash means to places if file in the
parent directory above the project
folder the file dot means to include all
files located in the current folder this
is sure that you character any folders
and hidden files located in your project
folder
now let's check our zip file you can run
the following command to check your zip
file again I've copied this command for
my clipboard but you can find this
command in our attached knowledge center
article unzip l dot dot forward slash -
score function dot zip the - L option
will list your zip file without
extracting it from here we can see the
function handler source files are
located in the root of the zip file
alternatively if you would like to use
Windows you will need to go to your
project folder and select all the
contents of your folder now I'm mr.
George the windows and demonstrate how
to do this in a Windows environment now
we're in my Amazon workspaces ivory
opened up my project folder now you can
see I have my main function file and my
dependencies to create a deployment
package select all your files right
click go to send to and select compress
zip folder name your zip file for your
function this case we're calling it
video demo dot zip now do you have it
appoint a package you can upload it to
your lander function using the console
or the command line first we use the
console as you can see I've already
logged into my a device management
console and gone to the lambda dashboard
from here select your function under the
function code section select upload a
zip file and select upload go to your
project folder and your zip file and
select your zip file click Save
after your upload completes you can now
test your function
should you just doing the CLI you can
use the a double s lambda update
function code command let's switch back
to our terminal session returning back
to our terminal window you can use the
ad FS CLI to to update your function
using the update function code command
again I've copied this command from my
clipboard we can find the example of
this command in the attached knowledge
center article type the command 80s
lamda update - function - code - -
function - name and the name of your
function in this case video demo and - -
zip - file file B colon four slash four
slash and the location of your zip file
in this case we're going to go to dot
dot four slash my underscore function
dot zip
when you run this command the CLI will
upload your function code to the lambda
endpoints you can find further options
for using this command in the ATS lambda
documentation if you run into a module
now found errors check the share that
you've installed the missing module to
your local project folder and check that
it is in the root folder of your zip
file