Configuring region in Node.js AWS SDK

前端 未结 14 1535
失恋的感觉
失恋的感觉 2020-12-05 03:30

Can someone explain how to fix a missing config error with Node.js? I\'ve followed all the examples from the aws doc page but I still get this error no matter what.

14条回答
  •  春和景丽
    2020-12-05 04:24

    You can resolve this issue right in your project directory.

    1. npm i -D dotenv.
    2. Create .env file in root of our project.
    3. Set environment variable AWS_SDK_LOAD_CONFIG=1 in that .env file.
    4. const {config} = require("dotenv"); in the same file where you configure connection to DynamoDB.
    5. config() before you new AWS.DynamoDB().

    P.S. As someone have mentioned before, problem is that Node doesn't get data from your aws.config file

提交回复
热议问题