Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

4,138 views
Skip to first unread message

Librae L

unread,
Mar 12, 2017, 12:31:06 AM3/12/17
to Node-RED
Hi folks,

Recently I found this issue: if I use *let* keyword in function node, the flows refuse to run.
If use Node-RED v0.16.2 or newer, the debug tab will prompt:
"SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode"
While if use older versions, nothing will happen and the flow will just not be running.

Thanks to suggestion of @nlecaude, I found the possible solution to use these keywords, like:

function log() {
    "use strict";
    let i = 1;
    node.warn(i);
}

log();
return msg;

Thus the flows will run and behave normally.

Post it here in case anyone interested.

Thanks,
Librae

Mark Setrem

unread,
Mar 12, 2017, 4:48:59 AM3/12/17
to Node-RED
In the comments on the slack channel you stated you were using node.js v4.x which only supports the use of let in strict mode (hence the error and the solution).

Newer versions of nodejs fully support let
You said you were going to investigate newer versions of nodejs.

Does this mean you have and found it's an issue in nodejs v6?


Julian Knight

unread,
Mar 12, 2017, 8:16:52 AM3/12/17
to Node-RED
Thanks for sharing, yes we are in that odd place between releases of ECMAscript and not all features are fully supported in Node.JS yet - because the V8 engine doesn't yet support them, depending on the version being used. This is not a Node-RED issue of course.

These issues should disappear once we've all moved to Node v6+

You can see what is supported by each version of Node.JS at this website: http://node.green/
A more detailed view is available here: http://kangax.github.io/compat-table/es6/

Although the first link shows let supported in v4, the second link shows that it is actually partial support only.

Librae

unread,
Mar 12, 2017, 10:49:12 AM3/12/17
to node...@googlegroups.com
Hi,

Mark, yes you hit the point. Sorry I forgot to post my result on Node.js version: v7.4.0, it works normally.
And the reason my Node.js version is 4.5.0 is because I am using Node-RED in docker and the docker image is out-of-date.

Well it doesn't matter, all clear!

Thank you for the clarification Julian, I'll move on to update my environment.

Librae

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/202fefaf-48de-46a9-ba37-1a58386f32b2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Mar 12, 2017, 2:18:44 PM3/12/17
to node...@googlegroups.com
Did you try Node v6.10.x ? as that is the LTS version we support...

Librae

unread,
Mar 14, 2017, 4:49:01 AM3/14/17
to node...@googlegroups.com
Yes, it works good on Node v6.10.x

13 Mar 13:44:14 - [info] Node-RED version: v0.16.2
13 Mar 13:44:14 - [info] Node.js  version: v6.10.0

On Mon, Mar 13, 2017 at 2:18 AM, Dave C-J <dce...@gmail.com> wrote:
Did you try Node v6.10.x ? as that is the LTS version we support...

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages