# Expose Node.js globals to function node

**URL:** https://discourse.nodered.org/t/expose-node-js-globals-to-function-node/38101
**Category:** Feature Requests
**Created:** [27 December 2020 17:28 UTC](https://discourse.nodered.org/t/expose-node-js-globals-to-function-node/38101 "2020-12-27T17:28:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tdiam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tdiam/32/34311_2.png) [@tdiam](https://discourse.nodered.org/u/tdiam)
#### Post date: [27 December 2020 17:28 UTC](https://discourse.nodered.org/t/expose-node-js-globals-to-function-node/38101/1 "2020-12-27T17:28:23Z")

</div>

Is there a policy on which of the [Node.js globals](https://nodejs.org/api/globals.html) are exposed to the function node?

I'd personally like to use the `URL` and `URLSearchParams` objects which are exposed globally in Node.js v10 onwards.

I could make a PR for this (adding to the `sandbox` object [here](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/function/10-function.js#L132) +tests would suffice I guess?)

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [27 December 2020 17:32 UTC](https://discourse.nodered.org/t/expose-node-js-globals-to-function-node/38101/2 "2020-12-27T17:32:34Z")

</div>

you could add them to the global context in settings.js then they would be available in the function node. See the "Global context" section of [https://nodered.org/docs/user-guide/writing-functions](https://nodered.org/docs/user-guide/writing-functions)

---

<div class="post-metadata">

### Author: ![tdiam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tdiam/32/34311_2.png) [@tdiam](https://discourse.nodered.org/u/tdiam)
#### Post date: [27 December 2020 18:02 UTC](https://discourse.nodered.org/t/expose-node-js-globals-to-function-node/38101/3 "2020-12-27T18:02:57Z")

</div>

Thanks, that's what I'm currently using.

It makes sense though to match the Node.js behavior by adding to the `Buffer`, timeout/interval functions etc. that are already exposed. It would improve a teeny bit on the learning curve and time-to-fresh-setup. However, it's not much so I get why it might as well stay as-is.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [25 February 2021 18:03 UTC](https://discourse.nodered.org/t/expose-node-js-globals-to-function-node/38101/4 "2021-02-25T18:03:08Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
