Skip to content

Support node:-prefixed core modules in parseModuleName - #5993

Merged
knolleary merged 2 commits into
node-red:mainfrom
shubhamrai9122-creator:fix-builtin-node-prefix-modules
Oct 14, 2026
Merged

knolleary merged 2 commits into
node-red:mainfrom
shubhamrai9122-creator:fix-builtin-node-prefix-modules

Conversation

@shubhamrai9122-creator

Copy link
Copy Markdown
Contributor

Summary

When checking if a module is a Node.js built-in, parseModuleName previously stripped the node: prefix and checked BUILTIN_MODULES.includes(moduleName.substring(5)).
However, core modules introduced in recent Node versions (such as node:sqlite, node:sea, node:test, node:test/reporters) are listed in require('module').builtinModules directly with the node: prefix and lack bare module aliases. Stripping the prefix caused isBuiltIn to evaluate to false, causing Node-RED to treat them as external npm packages and fail validation because : is not a valid npm package name character.

This change checks both BUILTIN_MODULES.includes(moduleName) and BUILTIN_MODULES.includes(moduleName.substring(5)) when the module starts with node:.
Unit tests have been added to verify that node: prefixed built-in modules are recognized as built-ins without triggering npm installation or erroring.

Some core modules introduced in recent Node versions (such as node:sqlite,
node:sea, node:test) are listed in require('module').builtinModules
directly with the 'node:' prefix and lack bare module names.
When checking whether a 'node:'-prefixed module is built-in, check
both the full moduleName and the stripped substring against BUILTIN_MODULES.

Fixes node-red#5991

Signed-off-by: shubhamrai9122-creator <[email protected]>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: shubhamrai9122-creator / name: shubhamrai9122-creator (91b5492)

@knolleary

Copy link
Copy Markdown
Member

Hi @shubhamrai9122-creator

The unit tests are failing for the code in this area:

  1) externalModules api
       checkFlowDependencies
         skips install for node: prefixed built-in modules:
     Error: the array [
  {
    "error": "Error: Invalid module name"
    "module": {
      "builtin": false
      "known": false
      "module": "node:test"
      "spec": "node:test"
      "subpath": ""
      "version": [undefined]
    }
  }
] was thrown, throw an Error :)

module.builtinModules does not list prefix-only modules such as
node:test on Node 22, so use isBuiltin() which handles both forms.
@knolleary
knolleary merged commit ebf49e9 into node-red:main Oct 14, 2026
3 checks passed
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 this pull request may close these issues.

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

2 participants