Generate uuid failed

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

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

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

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

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’);

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