# Generate uuid failed

**URL:** <https://community.postman.com/t/generate-uuid-failed/7281>\
**Category:** Help Hub\
**Tags:** pre-request\
**Created:** [August 21, 2019, 2:59am UTC](https://community.postman.com/t/generate-uuid-failed/7281 "2019-08-21T02:59:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joechou188](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@joechou188](https://community.postman.com/u/joechou188)\
**Post date:** [August 21, 2019, 2:59am UTC](https://community.postman.com/t/generate-uuid-failed/7281/1 "2019-08-21T02:59:37Z")

</div>

**Describe the bug**  
Error: Cannot find module ‘uuid/v4’

**To Reproduce**

1. Write the script below in “Pre-request Script”:  
uuidv4 = require(‘uuid/v4’);  
pm.globals.set(‘uuid’, uuidv4());
2. Use the globals variable - “uuid” in request body.
3. Click “Send” to send a POST request.

**Expected behavior**  
Generate a version 4 uuid before sending request.

**Screenshots**

 ![postman_issue](https://us1.discourse-cdn.com/getpostman/original/2X/d/d61d913d42dc0127b98ac364f47bafaccd2b5f2a.png)

**App information**

- Postman Version: 7.5.0
- OS: Windows 10 Enterprise 1809

**Additional context**  
It works fine if I rewrite the script as below:  
uuid = require(‘uuid’);  
pm.globals.set(‘uuid’, uuid.v4());  
But it should be deprecate according to the link: [https://www.npmjs.com/package/uuid](https://www.npmjs.com/package/uuid)

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [August 21, 2019, 9:39am UTC](https://community.postman.com/t/generate-uuid-failed/7281/2 "2019-08-21T09:39:42Z")

</div>

It seems that uuidv4 is not included in Postman and this is why you are getting this error.

---

<div class="post-metadata">

**Author:** ![joechou188](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@joechou188](https://community.postman.com/u/joechou188)\
**Post date:** [August 21, 2019, 10:14am UTC](https://community.postman.com/t/generate-uuid-failed/7281/3 "2019-08-21T10:14:03Z")

</div>

I’m afraid that I don’t get the picture. Could you tell me how to include it in the Postman?

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [August 21, 2019, 11:27am UTC](https://community.postman.com/t/generate-uuid-failed/7281/4 "2019-08-21T11:27:31Z")

</div>

Postman comes with a few node modules that are already bundled with the app. Adding other modules creates complications and you should avoid it if possible.

Just use the uuid lib that already exists in Postman.

const uuid= require(‘uuid’);

---

<div class="post-metadata">

**Author:** ![joechou188](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@joechou188](https://community.postman.com/u/joechou188)\
**Post date:** [August 22, 2019, 2:35am UTC](https://community.postman.com/t/generate-uuid-failed/7281/5 "2019-08-22T02:35:15Z")

</div>

True. OK, I’ll keep using the existing lib. Thanks for your suggestion.🙂
