### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

When running a lambda using E6S export syntax:

```
export const handler = (event) => {
  console.log("hello world");
  console.log(event);

  return event;
};
```

with `"type": "module"` set in my `package.json` I get the following error:

```
ERROR   Uncaught Exception      {"errorType":"Error","errorMessage":"Must use import to load ES Module: /var/task/index.js\nrequire() of ES modules is not supported.\nrequire() of /var/task/index.js from /var/runtime/UserFunction.js is an ES module file as it is a .js file whose nearest parent package.json contains \"type\": \"module\" which defines all .js files in that package scope as ES modules.\nInstead rename index.js to end in .cjs, change the requiring code to use import(), or remove \"type\": \"module\" from /var/task/package.json.\n","code":"ERR_REQUIRE_ESM","stack":["Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /var/task/index.js","require() of ES modules is not supported.","require() of /var/task/index.js from /var/runtime/UserFunction.js is an ES module file as it is a .js file whose nearest parent package.json contains \"type\": \"module\" which defines all .js files in that package scope as ES modules.","Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove \"type\": \"module\" from /var/task/package.json.","","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)","    at Module.load (internal/modules/cjs/loader.js:928:32)","    at Function.Module._load (internal/modules/cjs/loader.js:769:14)","    at Module.require (internal/modules/cjs/loader.js:952:19)","    at require (internal/modules/cjs/helpers.js:88:18)","    at _tryRequire (/var/runtime/UserFunction.js:75:12)","    at _loadUserApp (/var/runtime/UserFunction.js:95:12)","    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1063:30)"]}
```

I have provisioned the lambda with terraform:

```
resource "aws_lambda_function" "test" {
  filename         = "lambda.zip"
  function_name    = "test-function"
  role             = aws_iam_role.lambda.arn
  handler          = "index.handler"
  source_code_hash = data.archive_file.lambda_my_function.output_base64sha256

  runtime = "nodejs14.x"
}
```

### Expected Behavior

I'd expect the lambda to execute successfully without any errors.

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

docker compose up with example docker-compose.yaml file:

```
version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    network_mode: bridge
    ports:
      - "127.0.0.1:53:53"                # only required for Pro (DNS)
      - "127.0.0.1:53:53/udp"            # only required for Pro (DNS)
      - "127.0.0.1:443:443"              # only required for Pro (LocalStack HTTPS Edge Proxy)
      - "127.0.0.1:4510-4559:4510-4559"  # external service port range
      - "127.0.0.1:4566:4566"            # LocalStack Edge Proxy
    environment:
      - DEBUG=${DEBUG-}
      - DATA_DIR=${DATA_DIR-}
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
      - LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY-}  # only required for Pro
      - HOST_TMP_FOLDER=${TMPDIR:-/tmp/}localstack
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${TMPDIR:-/tmp}/localstack:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
```

Infrastructure is provisioned with the terraform in the example above. The code runs fine when using CommonJS.


Lambda is triggered with the following command:

```
awslocal lambda invoke --function-name test-function --invocation-type Event --cli-binary-format raw-in-base64-out --payload '{ "key": "value" }' output.txt
```

### Environment

```markdown
- OS: macOS Mojave 10.14.6 (18G9216)
- LocalStack: latest
```


### Anything else?

_No response_
import base64
import json
import logging
import os
import re
import shutil
import time
from io import BytesIO
from typing import Dict, TypeVar
import pytest
from botocore.exceptions import ClientError
from botocore.response import StreamingBody
from localstack.constants import LAMBDA_TEST_ROLE, TEST_AWS_ACCOUNT_ID
from localstack.services.awslambda import lambda_api
from localstack.services.awslambda.lambda_api import (
    LAMBDA_DEFAULT_HANDLER,
    get_lambda_policy_name,
    use_docker,
)
from localstack.services.awslambda.lambda_utils import (
    LAMBDA_RUNTIME_DOTNET6,
    LAMBDA_RUNTIME_DOTNETCORE31,