# Export variable to file

**URL:** <https://community.postman.com/t/export-variable-to-file/1004>\
**Category:** Help Hub\
**Created:** [February 21, 2018, 3:26am UTC](https://community.postman.com/t/export-variable-to-file/1004 "2018-02-21T03:26:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SatejMirpagar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/satejmirpagar/32/251_2.png) [@SatejMirpagar](https://community.postman.com/u/SatejMirpagar)\
**Post date:** [February 21, 2018, 3:26am UTC](https://community.postman.com/t/export-variable-to-file/1004/1 "2018-02-21T03:26:29Z")

</div>

Hi Team,

I am trying to export response to text file. I have tried nodejs module “fs” - but fails with error "Error running scripts: Error | Cannot find module ‘fs’.

Is there any way in postman to write response to file?

Thanks.

---

<div class="post-metadata">

**Author:** ![kunagpal](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kunagpal/32/9_2.png) [@kunagpal](https://community.postman.com/u/kunagpal)\
**Post date:** [February 21, 2018, 9:48am UTC](https://community.postman.com/t/export-variable-to-file/1004/2 "2018-02-21T09:48:23Z")

</div>

Hey @SatejMirpagar, inbuilt node libraries like `fs` have been disabled in the postman sandbox for the reasons of security. An alternative is to use [Newman](https://github.com/postmanlabs/newman), Postman’s CLI companion. A working example is provided here: [https://github.com/postmanlabs/newman/issues/413#issuecomment-316116450](https://github.com/postmanlabs/newman/issues/413#issuecomment-316116450)

An alternative to the above approach has been described here: [http://blog.getpostman.com/2017/09/01/write-to-your-local-file-system-using-a-postman-collection/](http://blog.getpostman.com/2017/09/01/write-to-your-local-file-system-using-a-postman-collection/)

---

<div class="post-metadata">

**Author:** ![SatejMirpagar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/satejmirpagar/32/251_2.png) [@SatejMirpagar](https://community.postman.com/u/SatejMirpagar)\
**Post date:** [February 22, 2018, 12:47am UTC](https://community.postman.com/t/export-variable-to-file/1004/3 "2018-02-22T00:47:20Z")

</div>

Thanks mate, appreciate it.
