Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.2K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda