I have the following issue... turns out I cannot test locally my aws lambda function over serverless-offline plugin in serverless framework for nodejs. Cannot do a simple GET request.
I am able to deploy to aws lambda with serverless deploy
command, but in order for better development experience of the team we need to deploy locally with serverless-offline, I followed this guide https://fauna.com/blog/develop-using-serverless-offline, but got stuck when I do a simple get request after running successfully serverless offline
command.
This I get when running serverless offline
successfully
But when I do a get request to the link http://localhost:3000/
through postman
I get the following error
It basically says cannot find node:url module but I did npm install url, but still same error throwing. I will insert the project tree and files below:
handler.js
//"use strict";
console.log("AJAJAJAJAJAJAJAJAJAAJAJ");
console.log("Printing module");
console.log(module.exports);
module.exports.hello = async (event) => {
console.log("whaaaaat");
return {
statusCode: 200,
body: JSON.stringify(
{
message: "Go Serverless v3.0! Your function executed successfully!",
input: event,
},
null,
2
),
};
};
serverless.yml
org: ortizjorge97
app: aws-node-http-api-project
service: aws-node-http-api-project
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
plugins:
- serverless-offline
- serverless-bundle
- serverless-dotenv-plugin
functions:
hello:
handler: handler.hello
events:
- httpApi:
path: /
method: get
package.json
{
"name": "aws-node-http-api-project",
"version": "1.0.0",
"description": "<!-- title: 'AWS Simple HTTP Endpoint example in NodeJS' description: 'This template demonstrates how to make a simple HTTP API with Node.js running on AWS Lambda and API Gateway using the Serverless Framework.' layout: Doc framework: v3 platform: AWS language: nodeJS authorLink: 'https://github.com/serverless' authorName: 'Serverless, inc.' authorAvatar: 'https://avatars1.githubusercontent.com/u/13742415?s=200&v=4' -->",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"serverless-bundle": "^5.5.0",
"serverless-dotenv-plugin": "^4.0.2",
"url": "^0.11.0"
},
"devDependencies": {
"serverless-offline": "^10.2.0"
}
}
I am newbie on aws stuff, so I dont know what could be happening.
I am using
- node 14.17.2
- MacOS Monterey m1 processor