HTTPs - require('fs') & certs follder

516 views
Skip to first unread message

Lawrence Griffiths

unread,
Oct 6, 2014, 4:25:13 AM10/6/14
to node...@googlegroups.com
Hi what am I doing wrong to get my HTTPs key & certificate files loaded I need to add 
 var fs=require('fs');
outside of the module def or I get the error
 [ReferenceError: fs is not defined]

Also I've placed my key & certificate files in Public folder it works and assume that is Ok?.
As I feel the node-red root should only contain core files. 

BTW have you guys made some performance improvements as my RPI cpu trace is almost a flat line now.
Used to be very spikey with a lot of I/O.

Thanks
Lawrence


Lawrence Griffiths

unread,
Oct 6, 2014, 10:29:19 AM10/6/14
to node...@googlegroups.com
Doh! what I should of said is I need to add  var fs=require('fs'); to settings.js

acoliveira Oliveira

unread,
Oct 6, 2014, 11:59:46 PM10/6/14
to node...@googlegroups.com
Lawrence, i will try this...
in settings.js add

    functionGlobalContext: {
        os:require('os'),
        SunCalc:require('suncalc'),
request:require('request'),
xparseString:require('xml2js').parseString,
S:require('string'),
strftime:require('strftime'),
versao:"1.0.0.01"
}

after npm install ..... if necessary
and in your flow, must be use context.global,   example context.global.os, context.global.fs, context.global.S

good luck.
ac

Lawrence Griffiths

unread,
Oct 7, 2014, 3:33:08 AM10/7/14
to node...@googlegroups.com
AC thanks I wish I hadn't rushed to post yesterday as I haven't made my issue clear!!

In settings.js to enable HTTPs you need to un-comment the following 

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

When you do this, you get [ReferenceError: fs is not defined]
To resolve this I added var fs=require('fs'); just before module.exports = {

I'm surprised at this and wondered if I was doing something wrong or it's an bug.

Lawrence

Paul Reed

unread,
Oct 21, 2014, 8:24:13 AM10/21/14
to node...@googlegroups.com
Yes I've found the same Lawrence when setting node-red https access. 
Unless var fs=require('fs'); just before module.exports = {   then I too get the error [ReferenceError: fs is not defined].

Maybe this needs to be included by default in the 'settings.js' file, as a comment, which can be uncommented for https.

Paul


Paul Reed

unread,
Oct 23, 2014, 3:38:37 PM10/23/14
to node...@googlegroups.com
For info, settings.js has now been updated in Github.

Thanks Nick
Reply all
Reply to author
Forward
0 new messages