shiftcode / dynamo-easy

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
https://shiftcode.github.io/dynamo-easy/
MIT License
204 stars 27 forks source link

TypeError: Reflect.getMetadata is not a function #339

Closed charlieporth1 closed 3 years ago

charlieporth1 commented 3 years ago

Describe the bug When installing prod only using npm install --only=prod when installed on AWS lambda

The stack trace is

{
    "errorType": "TypeError",
    "errorMessage": "Reflect.getMetadata is not a function",
    "stack": [
        "TypeError: Reflect.getMetadata is not a function",
        "    at /opt/node_modules/@shiftcoders/dynamo-easy/dist/decorator/impl/key/partition-key.decorator.js:14:40",
        "    at __decorate (/var/task/models/model.js:5:110)",
        "    at Object.<anonymous> (/var/task/models/model.js:17:1)",
        "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
        "    at Module.load (internal/modules/cjs/loader.js:863:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
        "    at Module.require (internal/modules/cjs/loader.js:887:19)",
        "    at require (internal/modules/cjs/helpers.js:74:18)",
        "    at Object.<anonymous> (/var/task/models/user.entity.js:12:17)"
    ]
}

Expected behavior For it to work?

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context N/A

michaellieberherr commented 3 years ago

see https://shiftcode.gitbook.io/dynamo-easy/get-started/installation

Gi60s commented 2 years ago

For anyone who follows the installation instructions and still has problems, put the import "reflect-metadata" at the top of your imports, not the bottom. I can't believe I banged my head against that one for so long. "Duh" moment.