{"id":15153,"library":"node-red-contrib-uuid","title":"Node-RED UUID Generator","description":"node-red-contrib-uuid is a Node-RED node designed for the simple and fast generation of RFC4122 compliant Universally Unique Identifiers (UUIDs) within Node-RED flows. It leverages the robust `uuid` npm package internally to ensure standard-compliant and cryptographically strong UUIDs. As of version 0.0.4-rc-1, it is in a release candidate stage, indicating active development and refinement. Node-RED contrib nodes typically follow an independent release cadence, often tied to feature enhancements or updates in their underlying dependencies like the `uuid` library. Its primary differentiator is providing a drag-and-drop solution for UUID generation directly within the Node-RED visual programming environment, abstracting the complexities of the underlying `uuid` library for flow developers.","status":"active","version":"0.0.4-rc-1","language":"javascript","source_language":"en","source_url":"https://github.com/agilitehub/node-red-modules/node-red-contrib-uuid","tags":["javascript","node-red","agilit-e","agilite","uuid","rfc4122"],"install":[{"cmd":"npm install node-red-contrib-uuid","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-contrib-uuid","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-contrib-uuid","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for generating RFC4122 compliant UUIDs.","package":"uuid","optional":false},{"reason":"Peer dependency as it is a Node-RED contribution node.","package":"node-red","optional":false}],"imports":[{"note":"These imports are for the underlying 'uuid' library, used by developers building Node-RED nodes or directly in a Node-RED Function node's 'Setup' tab. Users of 'node-red-contrib-uuid' interact with it visually in the Node-RED editor, not via JavaScript imports.","wrong":"import uuidv4 from 'uuid/v4'; // Deprecated since uuid@7, removed default export\nimport uuid from 'uuid'; console.log(uuid.v4()); // Default export removed in uuid@8+","symbol":"v4","correct":"import { v4 as uuidv4 } from 'uuid';"},{"note":"For CommonJS environments or older Node-RED Function nodes (pre-v1.0 or without 'Setup' tab module loading), you might see `const { v1 } = require('uuid');`. Ensure 'uuid' package is installed and accessible via `functionGlobalContext` or the Function node's module setup.","wrong":"const uuidv1 = require('uuid/v1'); // Deprecated deep import, use named exports","symbol":"v1","correct":"import { v1 as uuidv1 } from 'uuid';"},{"note":"For Node.js environments (including Node-RED) version 14.17.0+ or 15.6.0+, `crypto.randomUUID()` is a native, highly performant option for v4 UUIDs. This is an alternative to the 'uuid' package for purely random UUID generation within Function nodes.","wrong":"import { v4 } from 'uuid'; // While v4 is good, node:crypto.randomUUID is often faster in Node.js >=14.17.0/15.6.0.","symbol":"randomUUID","correct":"import { randomUUID } from 'node:crypto';"}],"quickstart":{"code":"[{\"id\":\"435a2d67.123456\",\"type\":\"inject\",\"z\":\"a1b2c3d4.567890\",\"name\":\"Trigger UUID\",\"props\":[{\"p\":\"payload\"}],\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"topic\":\"\",\"payload\":\"\",\"payloadType\":\"date\",\"x\":140,\"y\":100,\"wires\":[[\"e8f9g0h1.234567\"]]},{\"id\":\"e8f9g0h1.234567\",\"type\":\"uuid\",\"z\":\"a1b2c3d4.567890\",\"name\":\"Generate UUID\",\"version\":\"v4\",\"outputProperty\":\"payload\",\"x\":340,\"y\":100,\"wires\":[[\"210fe3dc.987654\"]]},{\"id\":\"210fe3dc.987654\",\"type\":\"debug\",\"z\":\"a1b2c3d4.567890\",\"name\":\"Show UUID\",\"active\":true,\"tosidebar\":true,\"console\":false,\"tostatus\":false,\"complete\":\"payload\",\"targetType\":\"msg\",\"statusVal\":\"\",\"statusType\":\"auto\",\"x\":540,\"y\":100,\"wires\":[]}]","lang":"json","description":"This Node-RED flow demonstrates basic UUID generation. It uses an Inject node to trigger the UUID node, which then generates a Version 4 UUID and outputs it to the debug sidebar."},"warnings":[{"fix":"Node-RED users: Ensure your Node-RED instance uses a supported Node.js version. Node-RED developers/maintainers: Regularly update the `uuid` dependency to its latest stable version, carefully reviewing its changelog for breaking changes and adapting import/usage patterns if necessary, especially regarding ESM and CJS compatibility for Node-RED's runtime.","message":"The underlying `uuid` library has undergone significant breaking changes across major versions (v7, v8, v9, v10, v11, v14). These include dropping Node.js 10.x, 12.x, 14.x, 18.x support, removing the default export, deprecating deep imports (e.g., `uuid/v4`), and transitioning to ESM-only in recent versions. While `node-red-contrib-uuid` abstracts this, maintainers must ensure the internal `uuid` dependency version is compatible with Node-RED's runtime Node.js version and handle `uuid`'s breaking changes.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Ensure `node-red-contrib-uuid` (or any custom Function node code using `uuid`) depends on `uuid` version 7 or higher. Check the `node-red-contrib-uuid`'s `package.json` for its `uuid` dependency version or update Node-RED and its modules to ensure modern, secure UUID generation.","message":"Older versions of the `uuid` library (specifically `uuid@3.x`) were deprecated due to their reliance on `Math.random()` for certain UUID versions, which is known to be cryptographically insecure. Using such versions can lead to predictable or duplicate UUIDs in sensitive applications.","severity":"deprecated","affected_versions":"<0.0.4"},{"fix":"After installing (`npm install node-red-contrib-uuid` in your Node-RED user directory, typically `~/.node-red`), always restart your Node-RED instance. If the issue persists, check the Node-RED startup logs for errors related to the node or run `npm audit` in your Node-RED user directory to identify dependency problems.","message":"Node-RED contrib nodes, including `node-red-contrib-uuid`, might not immediately appear in the palette after installation if Node-RED isn't restarted or if there are package installation issues. Errors during Node-RED startup or palette loading can also prevent nodes from showing up.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Navigate to your Node-RED user directory (usually `~/.node-red`) and run `npm install node-red-contrib-uuid`. Then restart your Node-RED instance (e.g., `node-red-restart` or `pm2 restart node-red`).","cause":"The package was not installed correctly in the Node-RED user directory or Node-RED was not restarted after installation.","error":"Error: Cannot find module 'node-red-contrib-uuid'"},{"fix":"While `node-red-contrib-uuid` maintains its own dependencies, this warning suggests its internal `uuid` version might be old. Monitor for updates to `node-red-contrib-uuid`. If the warning persists and you're using `uuid` directly in a Function node, update your `uuid` dependency to `@latest` (version 7 or higher) in your Node-RED `package.json` and ensure it's accessible.","cause":"The `node-red-contrib-uuid` package, or another dependency, is using an outdated and potentially insecure version of the `uuid` library.","error":"npm WARN deprecated uuid@X.Y.Z: Please upgrade to version 7 or higher."},{"fix":"In the Function node's 'Setup' tab, add 'uuid' as a module (e.g., 'uuidv4' for the variable name, 'uuid' for the module name). Then in your function code, you can use `const { v4: uuidv4 } = global.get('uuidv4')` or simply `const uuidv4 = require('uuid').v4;` if configured via `settings.js`.","cause":"Attempting to use `uuid` in a Node-RED Function node without properly declaring it as an external module.","error":"ReferenceError: uuidv4 is not defined"}],"ecosystem":"npm"}