Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 使用sam cli开发AWS无服务器Express应用程序时出错_Amazon Web Services_Express_Aws Lambda_Serverless_Aws Sam Cli - Fatal编程技术网

Amazon web services 使用sam cli开发AWS无服务器Express应用程序时出错

Amazon web services 使用sam cli开发AWS无服务器Express应用程序时出错,amazon-web-services,express,aws-lambda,serverless,aws-sam-cli,Amazon Web Services,Express,Aws Lambda,Serverless,Aws Sam Cli,每当我点击project的本地url作为get方法时,我会得到如下错误: 2018/08/07 15:19:41 Invoking index.handler (nodejs4.3) 2018/08/07 15:19:42 Mounting /e/serverless/sanlamFundRisk as /var/task:ro inside runtime container ←[32mSTART RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381

每当我点击project的本地url作为get方法时,我会得到如下错误:

2018/08/07 15:19:41 Invoking index.handler (nodejs4.3)
2018/08/07 15:19:42 Mounting /e/serverless/sanlamFundRisk as /var/task:ro inside runtime container
←[32mSTART RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381 Version: $LATEST←[0m
←[31mUnable to import module 'index': Error←[0m
←[31m    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)←[0m
←[32mEND RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381←[0m
←[32mREPORT RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381     Duration: 17.25 ms      Billed Duration: 100 ms Memory Size: 128 MB     Max Memory Used: 23 MB     ←[0m

2018/08/07 15:19:48 ←[31mFunction returned an invalid response (must include one of: body, headers or statusCode in the response object): %!s(<nil>)
←[0m
2018/08/07 15:19:41调用index.handler(nodejs4.3)
2018/08/07 15:19:42装载/e/serverless/sanlamFundRisk as/var/task:运行时容器内的ro
←[32mSTART RequestId:b4539898-148e-174b-a4f8-fdfccaaa4381版本:$LATEST←[0m
←[31M无法导入模块“索引”:错误←[0m
←[31 m at Function.Module.\u解析文件名(Module.js:325:15)
在Function.Module.\u加载(Module.js:276:25)
at Module.require(Module.js:353:17)
根据需要(内部/module.js:12:17)←[0m
←[32ID:b4539898-148e-174b-a4f8-fdfccaaa4381←[0m
←[32mREPORT RequestId:b4539898-148e-174b-a4f8-fdfccaaa4381持续时间:17.25毫秒计费持续时间:100毫秒内存大小:128 MB最大使用内存:23 MB←[0m
2018/08/07 15:19:48 ←[31M函数返回了无效的响应(响应对象中必须包含以下内容之一:正文、标题或状态代码):%!s()
←[0m

使用API网关与Lambda代理集成时,需要返回Lambda函数

例如:

  return {
    "isBase64Encoded": false,
    "statusCode": 200,
    "headers": {
      'Content-Type:': 'application/json'
    },
    "body": JSON.stringify({
        "example": "hello"
    })
  }

尝试升级到NodeJS 8.10。NodeJS 4.3已被弃用。