How do i install aws sam using npm?
-
AWS SAM web page: https://docs.aws.amazon.com/lambda/latest/dg/serverless_app.html
AWS SAM installation page: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html
Link to npm package (aws-sam-local) also provides installation instructions: https://www.npmjs.com/package/aws-sam-local
Set npm config: Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.
$ npm config set unsafe-perm=true
Install aws-sam-local package.
$ sudo npm install -g aws-sam-local > [email protected] postinstall /usr/local/lib/node_modules/aws-sam-local > go-npm install Downloading from URL: https://github.com/awslabs/aws-sam-local/releases/download/v0.2.11/sam_0.2.11_linux_amd64.tar.gz + [email protected] added 67 packages from 61 contributors in 4.809s
Verify version.
$ sam --version A newer version of the AWS SAM CLI is available! Your version: 0.2.11 Latest version: 0.6.1 See https://github.com/awslabs/aws-sam-local for upgrade instructions sam version 0.2.11
Start the AWS SAM api. For demo template.
$ sam local start-api A newer version of the AWS SAM CLI is available! Your version: 0.2.11 Latest version: 0.6.1 See https://github.com/awslabs/aws-sam-local for upgrade instructions 2018/10/27 08:16:07 Connected to Docker 1.37 2018/10/27 08:16:07 Runtime image missing, will pull.... 2018/10/27 08:16:07 Fetching lambci/lambda:nodejs8.10 image for nodejs8.10 runtime... nodejs8.10: Pulling from lambci/lambda 5be106c3813f: Pull complete e240967675e1: Pull complete 0fa7a4a5b472: Pull complete 11814d7919f1: Pull complete Digest: sha256:73639d4f85d8b173cb045e4acd9f3b049ed42830d538caceee8eb4f811a2cb59 Status: Downloaded newer image for lambci/lambda:nodejs8.10 Mounting index.handler (nodejs8.10) at http://127.0.0.1:3000/hello [POST] You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template.
© Lightnetics 2024