相关疑难解决方法(0)

Lambda 代码适用于 node v8.10 但不适用于 nodejs v10.x

我正在学习使用 v8.10 完成的 lambda 课程。我正在尝试使用 nodejs v10.x,因为这是我将来要用于我的项目的内容。

我不明白为什么“const uuid = require('uuid');” 行仅在 nodejs v10 中引发导入错误,但在 v8.10 中代码运行得很好。

代码:

const aws = require('aws-sdk');
const s3 = new aws.S3();
const uuid = require('uuid');

exports.handler = async (event) => {
    console.log("Get the event to our S3POC class - " + JSON.stringify(event));

    const newUUID = uuid.v4();

    console.log("The file name is:" + newUUID);

    //put our sentence into the s3 bucket
    return s3.putObject({
        Bucket: "helloworld-s3.arkhadbot.com",
        Key: "test" + ".json"
    });
};
Run Code Online (Sandbox Code Playgroud)

错误

Response:
{
  "errorType": "Runtime.ImportModuleError", …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services node.js aws-lambda

3
推荐指数
2
解决办法
4848
查看次数

标签 统计

amazon-web-services ×1

aws-lambda ×1

node.js ×1