Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda - Error: Cannot find module 'uuid/v4'

I am receiving this Error when trying to use UUID Module in AWS Lambda JavaScript code.

Error: Cannot find module 'uuid/v4'

I am not using AWSCLI or NPM, i am instead using the AWS Lambda dashboard to author the Lambda Functions in JavaScript.

const AWS = require('aws-sdk');
const AWSUUID = require('uuid/v4');
const AWSGamelift = new AWS.GameLift();

exports.handler = async (event) => 
{
 //...

Ive been searching Google nonstop trying to find a way to get the UUID Module to work. I do not want to have to setup and use an NPM environment.

Is there some method on the AWS Lambda dashboard to provide access to the UUID Module for Lambda code?

like image 588
DevilsD Avatar asked Mar 10 '20 01:03

DevilsD


1 Answers

You need to install uuid package. uuid recently did a breaking change, the way you use it. New way is

const {"v4": uuidv4} = require('uuid');

Hope this helps.

like image 50
Ashish Modi Avatar answered Nov 15 '22 13:11

Ashish Modi