2016-10-24 19:11:37 -07:00

41 lines
1.1 KiB
Markdown

<!--
title: Hello World AWS Lambda Node Example
menuText: Hello World Node Example
description: Create a nodeJS Lambda function on amazon web services
layout: Doc
-->
<!-- DOCS-SITE-LINK:START automatically generated -->
### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/using-external-libraries/node/)
<!-- DOCS-SITE-LINK:END -->
# Using External libraries in Node
Make sure serverless is installed. [See installation guide](/docs/01-guide/01-installing-serverless.md)
## 1. Install dependencies
For this example we are going to install the `faker` module from npm.
`npm install faker --save`
## 2. Install the faker module in your `handler.js` file
Inside of `handler.js` require your module.
`const faker = require('faker');`
## 1. Deploy
`serverless deploy` or `sls deploy`.
`sls` is shorthand for the serverless CLI command
Alternatively, you can run `npm run deploy` and deploy via NPM script defined in the `package.json` file
## 2. Invoke
`serverless invoke --function helloRandomName` or `sls invoke -f helloRandomName`
`-f` is shorthand for `--function`