I'm having some issues using UUID it keeps saying ...
# help
g
I'm having some issues using UUID it keeps saying
(0 , import_uuid.version) is not a function
anyone know how to fix this? I tried setting it in the nodeModules array on the function bundle but that did not changing anything.
f
Hey @Garret Harp, r u talking about the
uuid
npm package?
Can I see how you are importing/using it?
g
Yes thats the one here's how I am using it:
Copy code
import { version as uuidVersion } from 'uuid'

export const validateUuidV4 = (uuid: string) => {
	const v = uuidVersion(uuid)

	if (v !== 4) {
		throw new TypeError('Invalid id value')
	}
}
f
Can I see the full error?
g
Sure:
The left is the generated code for the lambda the right is what I actually put.
It looks like its only an issue with
version
because I can use
v4
just fine and create a uuid.
It looks like v4 is actually the only thing that works. version, validate, and parse all give the same error of (0, import_uuide.<function>) is not a function.
f
hmm.. works for me
this is my Lambda (an Api route)
Copy code
import { APIGatewayProxyResult } from "aws-lambda";

import { version as uuidVersion } from 'uuid'

export async function main(): Promise<APIGatewayProxyResult> {

  uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003');

  return {
    statusCode: 200,
    body: "hello",
  };
}
u shouldn’t put it inside
bundle.nodeModules
, but that’s not relevant to this error
g
Oh I just realized it installed version 3.3.2 of uuid instead of the most up to date. I assume that would be why.
f
try ^8.3.2
g
hmm still getting the same error
I'm going to reinstall all the node modules maybe its something funky with that
Ok yeah now its working, must have just kept the old version before. Thanks for the help.
f
Remember to remove it from the
bundle
option. It makes ur build slower.