我正在学习使用 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)