# HTTPS setting. \`fs\` module - huh?

**URL:** <https://discourse.nodered.org/t/https-setting-fs-module-huh/6531>\
**Category:** General\
**Created:** [7 January 2019 22:37 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531 "2019-01-07T22:37:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 January 2019 22:37 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531/1 "2019-01-07T22:37:58Z")

</div>

Sorry to drag this up (again?):

Looking in the settings.js file there are these lines:

```auto
// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
//var fs = require("fs");

```

Interesting. With this setting active, it forces https connections. Which is good for security.  
Not too important for me just now, but I like to keep my options open and learn. (Well: try to...)

So as I see it:

```auto
// Uncomment the following to make it available:

```

Which is self explanatory but for the preseeding (?) statement:

```auto
// The `https` setting requires the `fs` module.

```

Searching \>\>fs module node-red\<\< gets me results on the filesystem node more than the fs module.

(See attached)

How do I get more information on this "required `fs` module"?

 ![Screenshot%20from%202019-01-08%2009-36-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5a8888d0d4faf2d7c966b3d135400ac5913a05b7.png)

---

<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:** [7 January 2019 23:14 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531/2 "2019-01-07T23:14:16Z")

</div>

If you look further down in the `settings.js` file you'll find the commented out `https` setting. It looks like this:

```
//https: {
// key: fs.readFileSync('privatekey.pem'),
// cert: fs.readFileSync('certificate.pem')
//},

```

This is because the `https` setting requires you to provide two properties - `key` and `cert` and have them set to the appropriate certificate files needed for https. In order to load the content of those files, the commented out example uses the `fs.readFileSync` function to load the contents of those files.

But to do that, you need to have required the `fs` module - hence the comment at the top of the file.

The `fs` module is a built-in module of node.js. It is documented here: [https://nodejs.org/api/fs.html](https://nodejs.org/api/fs.html)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [7 January 2019 23:24 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531/3 "2019-01-07T23:24:42Z")

</div>

You don't need to install the 'fs' module @Trying_to_learn, just uncomment it in the NR settings, and node-RED will sort it out for you.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 January 2019 23:37 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531/4 "2019-01-07T23:37:07Z")

</div>

Thanks Paul and Nick.

I only asked because - to me - it was a bit confusing.

Nick,  
The original part I posted and the part you posted as "further down"....

That is a long way down.  
As the first part is "outside" the

module.exports = {

Part, and the part you mentioned was about .... 80 (?exact value? lines below the connection was lost to me.

If the lines:

> [@Trying\_to\_learn](#):
>
> // The `https` setting requires the `fs` module. Uncomment the following // to make it available: //var fs = require("fs");

and

> [@knolleary](#):
>
> //https: { // key: fs.readFileSync('privatekey.pem'), // cert: fs.readFileSync('certificate.pem') //},

Are related: why are they so far apart?

May I suggest the first part is put closer to the second, unless there is a reason that it is outside the

```auto
module.exports = {

```

scope.

If it is, could the second part be put a bit closer to the top so the association remains valid?

I am only asking/discussing this. It isn't important at this time for me. I am reading things and trying to take it in.

---

<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:** [7 January 2019 23:41 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531/5 "2019-01-07T23:41:09Z")

</div>

The `require` statement cannot be inside the `module.exports = { ... }` object.

The comment talks about the `https` setting. It doesn't take much to search the file for `https` and find the `https` setting. I see limited value in moving it further up.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 January 2019 23:47 UTC](https://discourse.nodered.org/t/https-setting-fs-module-huh/6531/6 "2019-01-07T23:47:29Z")

</div>

Ok.

Fair enough.

I suspected what you said to be true about:

> [@knolleary](#):
>
> The `require` statement cannot be inside the `module.exports = { ... }` object.

But wanted to be sure.
