Node-RED 3.x and Strict Mode JS

Hi All,
I did an upgrade from version 1 to version 3 and I found that (if I understood correctly) now Node use the strict mode to evaluate the code. Ok fine, I have to refactor some of my code due to stupid stuff like variable undefined, etc etc.
But now the question is: even if I use built in function, such as "env.get" or "node.log", those are recognized as error. If I run the flow it is working but it is annoying.

Anyone can give me a suggestion


The new code editor is telling you you have potentially buggy code. The fact it runs is immaterial.

If you really don't care about good code practices and potential sanity saving hints, you can disable the code checking in the settings.js file.

Personally, I strongly recommend fixing up your code.

can you show me the hint when you hover the squiggly line underneath it?

Hi Steve, yes I would like to use the strict mode and not by pass him, for that reason I'm looking for the solution. The error is : "Cannot find a name"


can you select that function & export it?

  • select node
  • right click
  • export

in the a reply, click the </> button and paste the exported JSON like this:

paste inbetween the triple back quotes

[{"id":"ab2d02930680cc2e","type":"inject","z":"62d141de5f418515","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":470,"y":420,"wires":[["8791c04293750b78"]]},{"id":"8791c04293750b78","type":"function","z":"62d141de5f418515","name":"function 1","func":"// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formatted Date string\nnode.warn(msg.payload = date.toString());\n// Return the message so it can be sent on\nreturn msg;","outputs":1,"noerr":3,"initialize":"","finalize":"","libs":[],"x":760,"y":420,"wires":[["16309043b2ea10a2"]]},{"id":"16309043b2ea10a2","type":"debug","z":"62d141de5f418515","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":420,"wires":[]}]

Works here:


Can you check the browsers console for errors? (F12 or right click inspect will get you into the console)

Hi Steve,
there are no errors. I checked when I deploy and also when I execute the flow. Unfortunately nothing...

When you upgraded, did you re-use the v1 settings file?

Show me:

  • your start up log (the text that appears after starting node-red until node-red has started
  • your settings.js file (likely in ~/.node-red/settings.js but your start up log will confirm that)

I did the upgrade with the script, so I don't know if it reused the old one, for sure the configuration inside, like secrets, env variable were not lost.

I start to paste the setting.js and I will post also the startup log

 * Copyright JS Foundation and other contributors,
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

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

process.env.Node_RED = "true";

module.exports = {
    // the tcp port that the Node-RED web server is listening on
    uiPort: process.env.PORT || 1880,

    // By default, the Node-RED UI accepts connections on all IPv4 interfaces.
    // To listen on all IPv6 addresses, set uiHost to "::",
    // The following property can be used to listen on a specific interface. For
    // example, the following would only allow connections from the local machine.
    //uiHost: "",

    // Retry time in milliseconds for MQTT connections
    mqttReconnectTime: 15000,

    // Retry time in milliseconds for Serial port connections
    serialReconnectTime: 15000,

    // Retry time in milliseconds for TCP socket connections
    //socketReconnectTime: 10000,

    // Timeout in milliseconds for TCP server socket connections
    //  defaults to no timeout
    //socketTimeout: 120000,

    // Maximum number of messages to wait in queue while attempting to connect to TCP socket
    //  defaults to 1000
    //tcpMsgQueueSize: 2000,

    // Timeout in milliseconds for HTTP request connections
    //  defaults to 120 seconds
    //httpRequestTimeout: 120000,

    // The maximum length, in characters, of any message sent to the debug sidebar tab
    debugMaxLength: 1000,

    // The maximum number of messages nodes will buffer internally as part of their
    // operation. This applies across a range of nodes that operate on message sequences.
    //  defaults to no limit. A value of 0 also means no limit is applied.
    //nodeMessageBufferMaxLength: 0,

    // To disable the option for using local files for storing keys and certificates in the TLS configuration
    //  node, set this to true
    //tlsConfigDisableLocalFiles: true,

    // Colourise the console output of the debug node
    //debugUseColors: true,

    // The file containing the flows. If not set, it defaults to flows_<hostname>.json
    //flowFile: 'flows.json',

    // To enabled pretty-printing of the flow within the flow file, set the following
    //  property to true:
    //flowFilePretty: true,

    // By default, credentials are encrypted in storage using a generated key. To
    // specify your own secret, set the following property.
    // If you want to disable encryption of credentials, set this property to false.
    // Note: once you set this property, do not change it - doing so will prevent
    // node-red from being able to decrypt your existing credentials and they will be
    // lost.
    credentialSecret: "*************************",

    // By default, all user data is stored in a directory called `.node-red` under
    // the user's home directory. To use a different location, the following
    // property can be used
    //userDir: '/home/nol/.node-red/',

    // Node-RED scans the `nodes` directory in the userDir to find local node files.
    // The following property can be used to specify an additional directory to scan.
    //nodesDir: '/home/nol/.node-red/nodes',

    // By default, the Node-RED UI is available at http://localhost:1880/
    // The following property can be used to specify a different root path.
    // If set to false, this is disabled.
    //httpAdminRoot: '/admin',

    // Some nodes, such as HTTP In, can be used to listen for incoming http requests.
    // By default, these are served relative to '/'. The following property
    // can be used to specifiy a different root path. If set to false, this is
    // disabled.
    //httpNodeRoot: '/red-nodes',

    // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
    // to apply the same root to both parts.
    //httpRoot: '/red',

    // When httpAdminRoot is used to move the UI to a different root path, the
    // following property can be used to identify a directory of static content
    // that should be served at http://localhost:1880/.
    //httpStatic: '/home/nol/node-red-static/',

    // The maximum size of HTTP request that will be accepted by the runtime api.
    // Default: 5mb
    //apiMaxLength: '5mb',

    // If you installed the optional node-red-dashboard you can set it's path
    // relative to httpRoot
    //ui: { path: "ui" },

    // Securing Node-RED
    // -----------------
    // To password protect the Node-RED editor and admin API, the following
    // property can be used. See for details.
    adminAuth: {
        type: "credentials",
        users: [{
            username: "admin",
            password: "********************************************",
            permissions: "*"

    // To password protect the node-defined HTTP endpoints (httpNodeRoot), or
    // the static content (httpStatic), the following properties can be used.
    // The pass field is a bcrypt hash of the password.
    // See
    //httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
    //httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},

    // The following property can be used to enable HTTPS
    // See
    // for details on its contents.
    // See the comment at the top of this file on how to load the `fs` module used by
    // this setting.
    //https: {
    //    key: fs.readFileSync('privatekey.pem'),
    //    cert: fs.readFileSync('certificate.pem')

    // The following property can be used to cause insecure HTTP connections to
    // be redirected to HTTPS.
    //requireHttps: true,

    // The following property can be used to disable the editor. The admin API
    // is not affected by this option. To disable both the editor and the admin
    // API, use either the httpRoot or httpAdminRoot properties
    //disableEditor: false,

    // The following property can be used to configure cross-origin resource sharing
    // in the HTTP nodes.
    // See for
    // details on its contents. The following is a basic permissive set of options:
    //httpNodeCors: {
    //    origin: "*",
    //    methods: "GET,PUT,POST,DELETE"

    // If you need to set an http proxy please set an environment variable
    // called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
    // For example - http_proxy=
    // (Setting it here will have no effect)
    // You may also specify no_proxy (or NO_PROXY) to supply a comma separated
    // list of domains to not proxy, eg -,

    // The following property can be used to add a custom middleware function
    // in front of all http in nodes. This allows custom authentication to be
    // applied to all http in nodes, or any other sort of common request processing.
    //httpNodeMiddleware: function(req,res,next) {
    //    // Handle/reject the request, or pass it on to the http in node by calling next();
    //    // Optionally skip our rawBodyParser by setting this to true;
    //    //req.skipRawBodyParser = true;
    //    next();

    // The following property can be used to pass custom options to the Express.js
    // server used by Node-RED. For a full list of available options, refer
    // to
    //httpServerOptions: { },

    // The following property can be used to verify websocket connection attempts.
    // This allows, for example, the HTTP request headers to be checked to ensure
    // they include valid authentication information.
    //webSocketNodeVerifyClient: function(info) {
    //    // 'info' has three properties:
    //    //   - origin : the value in the Origin header
    //    //   - req : the HTTP request
    //    //   - secure : true if req.connection.authorized or req.connection.encrypted is set
    //    //
    //    // The function should return true if the connection should be accepted, false otherwise.
    //    //
    //    // Alternatively, if this function is defined to accept a second argument, callback,
    //    // it can be used to verify the client asynchronously.
    //    // The callback takes three arguments:
    //    //   - result : boolean, whether to accept the connection or not
    //    //   - code : if result is false, the HTTP error status to return
    //    //   - reason: if result is false, the HTTP reason string to return

    // The following property can be used to seed Global Context with predefined
    // values. This allows extra node modules to be made available with the
    // Function node.
    // For example,
    //    functionGlobalContext: { os:require('os') }
    // can be accessed in a function block as:
    //    global.get("os")
    functionGlobalContext: {
        // os:require('os'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    // `global.keys()` returns a list of all properties set in global context.
    // This allows them to be displayed in the Context Sidebar within the editor.
    // In some circumstances it is not desirable to expose them to the editor. The
    // following property can be used to hide any property set in `functionGlobalContext`
    // from being list by `global.keys()`.
    // By default, the property is set to false to avoid accidental exposure of
    // their values. Setting this to true will cause the keys to be listed.
    exportGlobalContextKeys: false,

    // Context Storage
    // The following property can be used to enable context storage. The configuration
    // provided here will enable file-based context that flushes to disk every 30 seconds.
    // Refer to the documentation for further options:
    contextStorage: {
        default: {

    // The following property can be used to order the categories in the editor
    // palette. If a node's category is not in the list, the category will get
    // added to the end of the palette.
    // If not set, the following default order is used:
    //paletteCategories: ['subflows', 'common', 'function', 'network', 'sequence', 'parser', 'storage'],

    // Configure the logging output
    logging: {
        // Only console logging is currently supported
        console: {
            // Level of logging to be recorded. Options are:
            // fatal - only those errors which make the application unusable should be recorded
            // error - record errors which are deemed fatal for a particular request + fatal errors
            // warn - record problems which are non fatal + errors + fatal errors
            // info - record information about the general running of the application + warn + error + fatal errors
            // debug - record information which is more verbose than info + info + warn + error + fatal errors
            // trace - record very detailed logging + debug + info + warn + error + fatal errors
            // off - turn off all logging (doesn't affect metrics or audit)
            level: "info",
            // Whether or not to include metric events in the log output
            metrics: false,
            // Whether or not to include audit events in the log output
            audit: false

    // Customising the editor
    editorTheme: {
        projects: {
            // To enable the Projects feature, set this value to true
            enabled: false

I paste it as image:

as a test please:

  1. stop node-red
  2. rename /home/pikettbt/.node-red/settings.js to settings.js.old
  3. start node-red

This should generate a MUCH newer (and larger) settings.js file.

Please check the function node is now working as expected.

NOTE: You might find your security is lost or credentials are not decrypted - dont worry. If things go OK from the the above 3 steps, we can simply stop node-red, update the new setttings file to include your original credentials and adminAuth.

Also, your flows may not load - dont worry. We can fix that by renaming them to flows.json and flows_creds.json (or whatever default new empty flows files are created)

Same problem. Now I have a complete new setting.js that looks bigger and newer and before to copy the old flow or credential, I just add a function and test the node.log, but same behaviour. Below the startup


  1. what browser are you using?
  2. is the browser on the PI or an external computer?
  3. Can you try from another browser?
  4. Can you try from another browser on a different computer?

If you have no other browser available, what version is the problematic version?

Lastly, what do you see in the browser console->network for func.d.ts?

Im' using Edge, and the browser is on another computer. It's a bit difficult to try another browser and another computer because we are in a company environment. Let me think how could i do that.

What is interesting, is that "func.d.ts" in pending forever:

looks like its being blocked. an over zealous company security thing?

Can you try incognito / in-private or whatever edge calls it?

Same behaviour with incognito.

What I see is that all the file "d.ts" have a problem. I don't think stuff at firewall and network level, but I asked for an investigation


After the first investigation, my colleague didn't find something strange. But this afternoon he will do deep investigation

I completely forgot that I have Nginx on the same server working as reverse proxy. Now I'm checking if everything is ok, but it seems so. Still researching the issue

That would have been useful info upfront :slight_smile:

Can you access the browser on the device - my suspicion is it will work there (assuming the device has a GUI and the browser version is recent)

Hi Steve,
the Virtual machine where Node is installed is videoless, so I can't run a browser on the same machine, and I can't use actually the port 1880 from my laptop to Node due to firewall restriction. So now I'm trying to install the desktop environment on this Ubuntu server, in that way I can really test in local to esclude any problem with Reverse proxy or something else in the network.
I will let you know, thanks

1 Like