TypeError:无法分配为只读对象的属性“ exports”

时间:2019-10-06 07:59:48

标签: node.js amazon-web-services webpack aws-lambda amazon-dynamodb

  1. 尝试创建将插入DynamoDB表的AWS lambda。

2。尝试更改导入/要求

//我在哪里使用

const { ReportRepo } = require("../repos/reportsRepo");
const { withProcessEnv } = require("../util/dynamoDb");

const _client = withProcessEnv(process.env);
const _repo = new ReportRepo(_client);

// DynamoDB客户端

const { DocumentClient } = require("aws-sdk/clients/dynamodb");

const withProcessEnv = ({
  AWS_ENDPOINT,
  AWS_REGION,
  AWS_ACCESS_KEY_ID,
  AWS_SECRET_ACCESS_KEY
}) => () => {
  const options = {
    endpoint: AWS_ENDPOINT,
    region: AWS_REGION,
    accessKeyId: AWS_ACCESS_KEY_ID,
    secretAccessKey: AWS_SECRET_ACCESS_KEY
  };

  return new DocumentClient(options);
};

module.exports = withProcessEnv;

2 个答案:

答案 0 :(得分:0)

尝试在DynamoDB客户端中导出对象。

module.exports = {withProcessEnv};

table {
  overflow: hidden;
}

.activeCell,
tr:hover {
  background-color: #ffa;
}

td,
th {
  position: relative;
  width: 50px;
  height: 20px;
  text-align: center;
}

td:hover::after,
th:hover::after {
  content: "";
  position: absolute;
  background-color: #ffa;
  left: 0;
  top: -5000px;
  height: 10000px;
  width: 100%;
  z-index: -1;
}

答案 1 :(得分:0)

module.exports.handler = withProcessEnv;

选中