Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node with .cjs suffix does not load properly #4431

Open
Pezmc opened this issue Nov 10, 2023 · 0 comments · May be fixed by #4433
Open

Node with .cjs suffix does not load properly #4431

Pezmc opened this issue Nov 10, 2023 · 0 comments · May be fixed by #4433
Milestone

Comments

@Pezmc
Copy link

Pezmc commented Nov 10, 2023

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"
        },
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants