# Window object not available

**URL:** <https://discourse.nodered.org/t/window-object-not-available/8488>\
**Category:** General\
**Created:** [1 March 2019 07:23 UTC](https://discourse.nodered.org/t/window-object-not-available/8488 "2019-03-01T07:23:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![talhairfanbentley](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@talhairfanbentley](https://discourse.nodered.org/u/talhairfanbentley)\
**Post date:** [1 March 2019 07:23 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/1 "2019-03-01T07:23:56Z")

</div>

I have developed a custom node, which is using some front end objects,

```auto
1 Mar 12:09:40 - [warn] [imodel-query/imodel-query] ReferenceError: window is not defined

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 March 2019 08:00 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/2 "2019-03-01T08:00:41Z")

</div>

The runtime portion of your node runs in the node.js runtime, not in the browser. This means none of the browser-specific globals, such as `window`, exist.

---

<div class="post-metadata">

**Author:** ![talhairfanbentley](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@talhairfanbentley](https://discourse.nodered.org/u/talhairfanbentley)\
**Post date:** [1 March 2019 08:59 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/3 "2019-03-01T08:59:55Z")

</div>

So, what if I want to use some front end library (which is using window object) in my custom node.  
like, I drag an rest api node, and attach my custom node to it. and then have it working.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 March 2019 09:21 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/4 "2019-03-01T09:21:51Z")

</div>

What sort of library do you mean? Have you got an example?

You cannot use browser-specific libraries in the runtime part of your code; you need to use a node.js module.

---

<div class="post-metadata">

**Author:** ![talhairfanbentley](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@talhairfanbentley](https://discourse.nodered.org/u/talhairfanbentley)\
**Post date:** [1 March 2019 09:41 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/5 "2019-03-01T09:41:39Z")

</div>

Libraries that usually interact with the front end, but are running on node.js .  
and what do you mean by node.js module? what module can help me here?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 March 2019 09:53 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/6 "2019-03-01T09:53:09Z")

</div>

@talhairfanbentley by node.js module I mean a module published to npm for use with node.js.

You haven't explained what you are trying to do, so I can't point at any specific module to help you.

A node runs in the node.js runtime - it does not have anything to do with the browser. The only browser part is the node's edit dialog. Do you mean you want to use a 3rd party library when you are editing your node in the Node-RED editor?

Please describe in detail what you are trying to do.

---

<div class="post-metadata">

**Author:** ![talhairfanbentley](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@talhairfanbentley](https://discourse.nodered.org/u/talhairfanbentley)\
**Post date:** [1 March 2019 09:57 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/7 "2019-03-01T09:57:19Z")

</div>

okay It's like this:  
I'm creating a custom node. but I also have few external libraries with are related to [imodel](https://github.com/imodeljs/imodeljs) . To be exact I'm using imodel js front end libraries. in which the window object is being used.  
Now I'm not sure what i'm asking is possible or not.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 March 2019 10:02 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/8 "2019-03-01T10:02:57Z")

</div>

A node-red node runs as a headless piece of code in the server. It doesn't display anything on the screen. The imodel.js library you've linked to appears to be a library for displaying models on a webpage. Node-RED nodes don't run in the webpage - they run on the server.

There are modules such as node-red-dashboard that can be used to generate web-page dashboards served from node-red. It might be you want to create a custom node for node-red-dashboard that can be used to add an imodel.js viewer to a node-red-dashboard web page. But I am just guessing....

What do you want your custom node to actually do? Describe what functionality you want it to provide.

---

<div class="post-metadata">

**Author:** ![talhairfanbentley](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@talhairfanbentley](https://discourse.nodered.org/u/talhairfanbentley)\
**Post date:** [1 March 2019 10:10 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/9 "2019-03-01T10:10:55Z")

</div>

Certainly you guess gives me some idea.  
and as for now, I just need to query an imodel and display the result in the page or console. But only using frontend libs.

---

<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:** [1 March 2019 10:30 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/10 "2019-03-01T10:30:48Z")

</div>

For this I suspect the node-red-contrib-uibuilder project may be more appropriate as it lets you build a Node-RED dashboard the way to want using whatever libraries you want.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [1 March 2019 17:07 UTC](https://discourse.nodered.org/t/window-object-not-available/8488/11 "2019-03-01T17:07:16Z")

</div>

Yes, uibuilder can help here.

You will install the ibuilder nodes to your `userDir` folder - normally `~/.node-red` and add the names to Node-RED's settings.js file as per the documentation for uibuilder.

Then you can add a uibuilder node to your flow and it will make the front-end libraries available.

You will need to then amend the default `index.html` file to load the libraries into the browser & make any required changes to the rest of the web page. Then you may have to alter `index.js` to do whatever imodel needs.

uibuilder then also provides you with a communications channel between the Node-RED server back-end and your front-end code so that you can pass data back and forth as needed.
