sam local start-api Невозможно импортировать модуль

Я просто создаю лямбда-функцию с содержимым (имя файла - check.js):

exports.handler = async (event, context, callback) => {
    console.log("My message");
};

И содержание template.yaml

    AWSTemplateFormatVersion : '2010-09-09'
    Transform: AWS::Serverless-2016-10-31
    Description: My first serverless application.
    Resources:
      CreateOrder:
        Type: AWS::Serverless::Function
        Properties:
          Handler: check.handler
          Runtime: nodejs8.10
          Timeout: 30
          MemorySize: 512
          Events:
            Step1:
              Type: Api
              Properties:
                Path: /
                Method: any

После этого я использовал conmand: sam local start-api

Я получил ошибку:

Fetching lambci/lambda:nodejs8.10 Docker container image......
2018-11-19 11:33:48 Mounting D:\project\lambda1\BbeOrder as /var/task:ro inside runtime container
[32mSTART RequestId: 5b55437b-da83-132e-ea70-7661e1dbe757 Version: $LATEST[0m
[31mUnable to import module 'check': Error[0m
[31m    at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)[0m
[32mEND RequestId: 5b55437b-da83-132e-ea70-7661e1dbe757[0m
[32mREPORT RequestId: 5b55437b-da83-132e-ea70-7661e1dbe757     Duration: 3.66 ms       Billed Duration: 100 ms Memory Size: 512 MB     Max Memory Used: 31 MB  [0m
2018-11-19 11:33:49 No Content-Type given. Defaulting to 'application/json'.
2018-11-19 11:33:49 127.0.0.1 - - [19/Nov/2018 11:33:49] "GET / HTTP/1.1" 200 -
2018-11-19 11:33:50 127.0.0.1 - - [19/Nov/2018 11:33:50] "GET /favicon.ico HTTP/1.1" 403 -

Я помню, прежде чем все в порядке. Но это проблема, так как я переустановил Docker. Пожалуйста, помогите мне в этой проблеме.

0 ответов

I encountered the same issue, reinstalled Docker and got a new error that didn't allow me to share drives for some reason. I then followed this article:https://tomssl.com/2018/01/11/sharing-your-c-drive-with-docker-for-windows-when-using-azure-active-directory-azuread-aad/

Basically, the article tells you to add a new local user as an admin to the computer. I then ran, docker and got a new error with permission denied, I ended up changing my password on my PC to something shorter and for some reason it worked.

I think the root of the reason for my second problem (shared drives sign-in problem) was that I had a really long password on my computer.

Hope this helps anyone in the future.

Другие вопросы по тегам