简体   繁体   English

无服务器离线 - API REST 节点 typescript

[英]Serverless-offline - API REST node typescript

I created a project serverless and I am having a trouble:我创建了一个无服务器项目,但遇到了麻烦:

sls create --template aws-nodejs-typescript
npm install serverless-offline --save-dev

then, inside the file serverless.ts I add in:然后,在文件 serverless.ts 中添加:

plugins: ['serverless-webpack', 'serverless-offline'],

So I run the project with the command:所以我使用以下命令运行项目:

serverless offline --stage dev

As response I have:作为回应,我有:

**POST | http://localhost:3000/dev/hello                              
POST | http://localhost:3000/2015-03-31/functions/hello/invocations**

The request with POST http://localhost:3000/dev/hello using body {“name”: “Andre”} don´t answer, I don´t know why the project don´t response to the request, it only show “sending request” in postman and keeps showing this. POST http://localhost:3000/dev/hello 使用 body {“name”: “Andre”} 的请求不回答,我不知道为什么项目不响应请求,它只显示postman 中的“发送请求”并不断显示。 But if I use the address GET http://localhost:3000 I have a response saying that existing routes are:但是,如果我使用地址 GET http://localhost:3000 我有一个回复说现有的路线是:

{
    "currentRoute": "get - /",
    "error": "Serverless-offline: route not found.",
    "existingRoutes": [
        "post - /dev/hello"
    ],
    "statusCode": 404
}

Please, could you make this process?请问,你能做这个过程吗? I Think there is a bug in the template that was created我认为创建的模板中存在错误

Thank you.谢谢你。

The problema was the version of nodejs.问题是nodejs的版本。

I was usgin node 16.我是usgin节点16。

Now I am using node LTS 14.现在我正在使用节点 LTS 14。

Problem solved.问题解决了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 serverless-offline 可选路径参数 - serverless-offline optional path parameter 带有无服务器离线阶段中断路由的 aws-serverless-express - aws-serverless-express with serverless-offline stage breaks routing 无法获取路径:/{proxy+} 工作(无服务器离线) - Cant get path: /{proxy+} to work (serverless-offline) 如何在 function 之前在 mocha 测试中启动 serverless-offline - How to start serverless-offline in mocha test before function 在本地 docker localhost:8000 中使用 dynamodb 和在 localhost:4500 上运行的 serverless-framework serverless-offline 应用程序 - Using dynamodb in local docker localhost:8000 with serverless-framework serverless-offline application running on localhost:4500 如何记录节点打字稿 AWS 无服务器 API? - How to document Node typescript AWS serverless API? “内部服务器错误”无服务器节点Rest API - “Internal server error” serverless node rest api 如何在无服务器离线中使用 Cognito 事件/触发器调用 lambda 以进行本地测试 - How to invoke lambda with Cognito event/trigger in serverless-offline for local test Serverless-offline 抛出“配置错误”或“无法读取未定义的属性‘选项’” - Serverless-offline throws "Configuration error" or "Cannot read property 'options' of undefined" 如何摆脱包装无服务器离线 html 响应正文的双引号? - How to get rid of double quotes wrapping serverless-offline html response body?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM