问题
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.
来源:https://stackoverflow.com/questions/48356841/how-can-i-use-axios-in-lambda