types/uuid - Uncaught TypeError Object(...) is not a function

less than 1 minute read

If you want to check if a string is an UUID (Universally Unique Identifier, aka GUID) in reactjs.

You can use the NPM package @types/uuid to do it.

Here I created a helper class to validate a string.

import { validate as uuidValidate } from 'uuid';

export class StringUtils {
    static isValidUuid = (identifier: string) => {
        return uuidValidate(identifier);

But I’ve encountered the following error:

Uncaught TypeError: Object(...) is not a function
    at Function.Bc.isValidUuid (VM97 main.5b67c597.chunk.js:17)

To fix it, I have to install the npm package uuid. As it has a dependency on it.

yarn add uuid


npm install uuid --save
SUN Jiangong

SUN Jiangong

A senior .NET engineer, software craftsman. Passionate about new technologies.