Skip to content

module initialization error: Error happens only on Lambda #11

@faizhasim

Description

@faizhasim

I am requiring a module provision-dynamodb in my serverless project (in which I'm one of the authors, so I can make changes to that module, if needed). Execution in lambda fails.

This is my lambda function:

const processConfigTables = require('provision-dynamodb');

export const hello = async (event: Object, context: Object, callback: Function) : any => {
  try {
    const result = await processConfigTables([{
      "name":"test-table",
      "readStrategy": {
        "name":"capacity-ratio",
        "upperThresholdRatio":0.8,
        "lowerThresholdRatio":0.15,
        "incrementRatio":3,
        "decrementRatio":0.8,
        "lowerBoundUnit":1,
        "upperBoundUnit":28},
      "writeStrategy": {
        "name":"capacity-ratio",
        "upperThresholdRatio":0.8,
        "lowerThresholdRatio":0.15,
        "incrementRatio":3,
        "decrementRatio":0.8,
        "lowerBoundUnit":1,
        "upperBoundUnit":28
      }
    }]);
    console.log('result = ', result);

    const response = {
      statusCode: 200,
      body: JSON.stringify({ok: true}),
    };

    return callback(null, response);
  } catch (err) {
    console.error('err', err);
    return callback(null, {
      statusCode: 500,
      body: JSON.stringify(err),
    });
  }
};

I got this error:

module initialization error: Error
    at Error (native)
    at Object.fs.readdirSync (fs.js:808:18)
    at Object.<anonymous> (/var/task/handler.js:3177:4)
    at Object.96.../package.json (/var/task/handler.js:3197:4)
    at s (/var/task/handler.js:1:682)
    at /var/task/handler.js:1:733
    at Object.102.nconf (/var/task/handler.js:4220:142)
    at s (/var/task/handler.js:1:682)
    at /var/task/handler.js:1:733
    at Object.105../config (/var/task/handler.js:4229:519)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions