### 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 sys
import tempfile
import threading
import time
import traceback
import uuid
from multiprocessing import Process, Queue
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from localstack import config
from localstack.config import LAMBDA_TRUNCATE_STDOUT, TMP_FOLDER
from localstack.constants import DEFAULT_LAMBDA_CONTAINER_REGISTRY
from localstack.runtime.hooks import hook_spec
from localstack.services.awslambda.lambda_utils import (
    API_PATH_ROOT,
    LAMBDA_RUNTIME_PROVIDED,
    get_container_network_for_lambda,
    get_main_endpoint_from_container,
    get_record_from_event,
    is_java_lambda,
    is_nodejs_runtime,
    rm_docker_container,
    store_lambda_logs,
)
from localstack.services.install import GO_LAMBDA_RUNTIME, INSTALL_PATH_LOCALSTACK_FAT_JAR
from localstack.utils.aws import aws_stack
from localstack.utils.aws.aws_models import LambdaFunction
from localstack.utils.aws.dead_letter_queue import (
    lambda_error_to_dead_letter_queue,
    sqs_error_to_dead_letter_queue,
)