'Module not found: Error: Package path ./v4 is not exported from package

I was building a react project but when I tried to run it. It showed the following error:

Module not found: Error: Package path ./v4 is not exported from package
....\node_modules\uuid (see exports field in ....\node_modules\uuid\package.json)

I imported using the following code:

import uuidv4 from 'uuid/v4';


Solution 1:[1]

Looks like an import issue in uuid. Try updating the import statement as:

import { v4 as uuidv4 } from 'uuid';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 neeraj tk