Do I have to install the axios module locally and then deploy it to lambda or is there a way to do it through the inline code editor as well in the browser?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Lambda doesn't actually bundle your package dependencies for you, except the AWS package, so yes you'd need to install it locally, zip it together and upload to the Lambda console.
回答2:
In the folder where your lambda script is present (index.js) run following command -
npm install axios
You should see node_modules
directory getting created in the same directory as index.js. Now zip both these together (index.js and npm_modules) and upload it you your lambda as zip. You can repeat this with other npm module dependencies you have. If you do not want to repeat these manual steps again for each module create package.json
file and add all your module dependencies there and just run npm install
once.