Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.2K
Views
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?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report

0

AWS Lambda Layers is an option for this if we don't want to set up any npm environment.

Create a new layer for your Lambda function from the AWS console and upload the zip file from the node_modules directory that contains the uuid npm package.

A few things to remember to get this working:

  1. The directory structure should be kept as per the AWS documentation https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path

enter image description here

This is important, otherwise the Lambda function will not recognize the packages.

  1. Your Lambda function's IAM role must have the lambda:GetLayerVersion action permission, otherwise you'll run into a problem with the missing package. This is clearly explained in the documentation mentioned above.

Once done, you can run your code. response example

enter image description here

The nodejs folder structure is as follows

enter image description here

over 4 years ago · Santiago Trujillo Report

0

navigate to that file, and look around line number 3 in node_modules/expo-constants/exponentConstants.web.js

import uuidv4 from 'uuid/v4

and change it to:

import {v4 as uuidv4} from 'uuid';

This error happens because of the file structure in node_modules/uuid, if you look there is no longer a uuidv4 to import and instead they export a v4. You could change all the places where the developers wrote uuidv4 to v4 but using the { this as that } syntax you don't have to rewrite a bunch of code.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!