Skip to content

node:-scoped core modules (e.g. node:sqlite, node:test) cannot be used in a Function node as a module - halts runtime #5991

Closed

Description

@Steve-Mcl

Current Behavior

With Node adding scoped built-ins like node:test and node:sqlite, I'd like to use them as modules in a Function node - but Node-RED's runtime doesn't handle these correctly, and the flow halts.

Declaring node:sqlite or node:test as a Function node module leaves the node permanently flagged invalid, with the module permanently "missing". Deploying gives a toast: "Flows stopped due to missing modules", listing both as install_not_allowed. The node itself then shows a persistent canvas error: "Invalid properties: - Module node:sqlite missing" (same for node:test). There's no working path to clear this short of removing the module.

Root cause is in @node-red/registry/lib/externalModules.js, parseModuleName():

const BUILTIN_MODULES = require('module').builtinModules;
...
if (/^node:/.test(moduleName)) {
    isBuiltIn = BUILTIN_MODULES.includes(moduleName.substring(5))
} else {
    isBuiltIn = BUILTIN_MODULES.includes(moduleName)
}

Some builtins are listed in module.builtinModules with the node: prefix baked into the string itself, with no bare alias. On Node 24.19.0:

> require('module').builtinModules.filter(m => m.startsWith('node:'))
[ 'node:sea', 'node:sqlite', 'node:test', 'node:test/reporters' ]

For node:-prefixed input, parseModuleName strips the prefix before checking the list, i.e. it checks whether bare sqlite is in the list. The list entry is the full string node:sqlite, so this never matches, and isBuiltIn comes back false. checkFlowDependencies() then treats it as an external npm dependency and calls installModule(), which runs it through validate-npm-package-name before anything else:

> require('validate-npm-package-name')('node:sqlite')
{ validForOldPackages: false, warnings: ['node:sqlite is a core module name'], errors: ['name can only contain URL-friendly characters'] }

The colon isn't a valid npm package name character, so this throws before any install is attempted - surfaced to the user as install_not_allowed, matching the toast exactly. I haven't checked node:sea or node:test/reporters directly, but the same code path applies to all four.

Expected Behavior

Declaring node:sqlite (or node:sea, node:test, node:test/reporters) as a module should resolve to Node's native builtin directly, with no npm install attempted and no "missing module" state - the same way node:fs or node:path already do.

The fix looks quite narrow for node:-prefixed input, parseModuleName should also check the unstripped string against BUILTIN_MODULES (i.e. BUILTIN_MODULES.includes(moduleName) using the full node:sqlite form), not only the stripped form.

Steps To Reproduce

  1. Run Node-RED on Node.js 22.5+ (native node:sqlite support) or Node.js 24.
  2. Add a Function node, open the Setup tab, add a module named node:test imported as test.
  3. Deploy.
  4. Deploy toast reports "Flows stopped due to missing modules" with node:test - install_not_allowed, and the node on the canvas is permanently flagged invalid: "Invalid properties: - Module node:test missing".
  5. Same result with node:sqlite imported as sqlite.

Example flow

[
    {
        "id": "f1_tab",
        "type": "tab",
        "label": "node:sqlite / node:test builtin bug",
        "disabled": false,
        "info": ""
    },
    {
        "id": "f1_node",
        "type": "function",
        "z": "f1_tab",
        "name": "check sqlite + test",
        "func": "node.warn(typeof sqlite.DatabaseSync);\nnode.warn(typeof test.test);\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "libs": [
            {
                "module": "node:sqlite",
                "var": "sqlite"
            },
            {
                "module": "node:test",
                "var": "test"
            }
        ],
        "x": 160,
        "y": 120,
        "wires": [[]]
    }
]

Environment

  • Node-RED version: 5.0.8
  • Node.js version: 24.19.0
  • npm version: 11.17.0
  • Platform/OS: Windows 11
  • Browser: n/a (runtime/deploy-time issue, not editor-UI specific)

Activity

  1. Steve-Mcl commented on Oct 10, 2026

    @Steve-Mcl
    ContributorAuthor

    Happy to raise a PR - I suggest this would go against main as a bug fix (but could equally go against dev as a feature)

    Let me know pls.

  2. Steve-Mcl commented on Oct 10, 2026

    @Steve-Mcl
    ContributorAuthor

    For when this gets picked up

    Node-RED's Monaco integration (@node-red/editor-client/.../monaco.js) has the same node: prefix gap, just in a different place - the knownModules table used to fetch type declarations for the Setup tab.

    sea.d.ts, sqlite.d.ts, and test.d.ts only declare declare module "node:sqlite" / "node:sea" / "node:test" - they dont have a bare alias!

    Example code I added to editor-client/src/js/ui/editors/code-editors/monaco.js:100 to test completions

            "node:sqlite": {package: "node", module: "node:sqlite", path: "node/sqlite.d.ts" },
            "node:sea": {package: "node", module: "node:sea", path: "node/sea.d.ts" },
            "node:test": {package: "node", module: "node:test", path: "node/test.d.ts" },
    
  3. added a commit that references this issue on Oct 14, 2026
    91b5492
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions