Skip to content

Node with .cjs suffix does not load properly #4431

Closed

Description

@Pezmc

Current Behavior

If a node uses the .cjs file extension, node-red appears to try and load it (it shows up in the setting palette), but it is not available in the list of nodes:

Example config:

  "node-red": {
    "nodes": {
      "common-js-lower-case": "lower-case-cjs.cjs",
      "esm-lower-case": "lower-case-mjs.mjs",
      "js-lower-case": "lower-case-js.js"
    }
}

Note that .cjs and .js appear to have been loaded (and .mjs fails with an ESM error, as expected):

Screenshot 2023-11-10 at 16 24 14

However, only .js is available in the list:

Screenshot 2023-11-10 at 16 23 24

Expected Behavior

Files with the .cjs file extension should behave exactly the same as ones with .js, i.e. load correctly and slow in the node list.

I suspect something in the loader is trying to load a .js file regardless of the node-red config in the package.json; but there are no visible error messages.

Steps To Reproduce

Repo with issue: https://github.com/Pezmc/node-red-test-node

Example flow

n/a

Environment

  • Node-RED version:
  • Node.js version: 3.1.10
  • npm version: 18.18.0
  • Platform/OS: MacOS
  • Browser: Chrome/Safari/Firefox
{
    "report": "diagnostics",
    "scope": "basic",
    "time": {
        "utc": "Fri, 10 Nov 2023 15:27:03 GMT",
        "local": "10/11/2023, 16:27:03"
    },
    "intl": {
        "locale": "en-GB",
        "timeZone": "CET"
    },
    "nodejs": {
        "version": "v18.18.0",
        "arch": "arm64",
        "platform": "darwin",
        "memoryUsage": {
            "rss": 121126912,
            "heapTotal": 45645824,
            "heapUsed": 41648840,
            "external": 1509484,
            "arrayBuffers": 227068
        }
    },
    "os": {
        "containerised": false,
        "wsl": false,
        "totalmem": 68719476736,
        "freemem": 846118912,
        "arch": "arm64",
        "loadavg": [
            4.421875,
            5.7548828125,
            6.6025390625
        ],
        "platform": "darwin",
        "release": "23.0.0",
        "type": "Darwin",
        "uptime": 1569557,
        "version": "Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000"
    },
    "runtime": {
        "version": "3.1.0-git",
        "isStarted": true,
        "flows": {
            "state": "start",
            "started": true
        },
        "modules": {
            "node-red": "3.1.0-git",
            "node-red-test-node": "0.0.1"
        },
    }
}

Activity

  1. added this to the 4.0 milestone on Jan 19, 2024
  2. knolleary commented on Jun 11, 2026

    @knolleary
    Member

    Closed via #5221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions