Node-RED IcedCoffeeScript Node
The `node-red-iced-coffeescript` package provides a custom node for the Node-RED low-code programming platform, enabling users to execute code written in IcedCoffeeScript within their flows. Node-RED is an open-source tool for wiring together hardware devices, APIs, and online services in event-driven applications, often used for IoT and automation. IcedCoffeeScript is a superset of CoffeeScript that introduced `await` and `defer` keywords for simplified asynchronous control flow, predating the native `async/await` features in modern JavaScript. This package, currently at version 1.0.7, effectively allows Node-RED flows to leverage IcedCoffeeScript's asynchronous syntax. However, given its last update was approximately nine years ago, and `iced-coffee-script` itself has not been updated in six years, the package is considered abandoned. Its primary differentiator, async handling, has been largely superseded by standard JavaScript capabilities. The package requires `iced-coffee-script` to be installed separately.
Common errors
-
Error: Cannot find module 'iced-coffee-script' in Node-RED debug log.
cause The `iced-coffee-script` compiler, a peer dependency, has not been installed on the system where Node-RED is running.fixRun `npm install -g iced-coffee-script` to install the compiler globally, then restart your Node-RED instance. -
SyntaxError: Unexpected token 'await' (or 'defer') in iced-coffeescript node.
cause This error is unlikely for IcedCoffeeScript itself, but could occur if trying to use *modern JavaScript's* `await` syntax directly in an IcedCoffeeScript node, or if the `iced-coffee-script` compiler itself is misconfigured or missing.fixEnsure the `iced-coffee-script` compiler is correctly installed. If attempting to use modern JavaScript `async/await`, switch to a standard Node-RED 'Function' node set to JavaScript, not an `iced-coffeescript` node.
Warnings
- deprecated The `node-red-iced-coffeescript` package is effectively abandoned, with its last commit over nine years ago. The underlying `iced-coffee-script` compiler also received its last update six years ago.
- gotcha This package relies on the `iced-coffee-script` compiler, which must be installed separately, either locally or globally, for the Node-RED node to function correctly. The `node-red-iced-coffeescript` package does not bundle or automatically install this dependency.
- gotcha IcedCoffeeScript's core value proposition (simplified asynchronous control flow via `await`/`defer`) has largely been superseded by native `async/await` in modern JavaScript (ES2017+). Using IcedCoffeeScript might introduce unnecessary complexity or reliance on outdated language features.
Install
-
npm install node-red-iced-coffeescript -
yarn add node-red-iced-coffeescript -
pnpm add node-red-iced-coffeescript
Imports
- Node-RED Editor Palette
Install via npm, then drag the 'iced-coffeescript' node from the palette in the Node-RED editor.
- IcedCoffeeScript Node (within a flow)
Wire messages into the 'iced-coffeescript' node within a Node-RED flow to execute IcedCoffeeScript logic.
- Node Definition (for Node-RED runtime)
import { IcedCoffeeScriptNode } from 'node-red-iced-coffeescript'The Node-RED runtime automatically loads and registers the node's definition files (e.g., `.js` and `.html`) from the installed npm package.
Quickstart
# 1. Install Node-RED (if not already installed)
sudo npm install -g --unsafe-perm node-red
# 2. Start Node-RED
node-red
# 3. In a new terminal, install the IcedCoffeeScript compiler globally (as recommended by the package README)
sudo npm install -g iced-coffee-script
# 4. Install the Node-RED IcedCoffeeScript node
npm install node-red-iced-coffeescript
# 5. Restart Node-RED to load the new node
node-red
// 6. Access the Node-RED editor (usually http://localhost:1880)
// 7. Drag an 'Inject' node, an 'iced-coffeescript' node, and a 'Debug' node onto the canvas.
// 8. Wire them together: Inject -> iced-coffeescript -> Debug.
// 9. Double-click the 'iced-coffeescript' node to edit its code.
// Replace the default content with the following IcedCoffeeScript example:
# IcedCoffeeScript code for the node:
msg.payload = "Hello, IcedCoffeeScript!"
# Example of IcedCoffeeScript's async features (for context, if `defer` was relevant)
# Not directly executable without an async operation, but demonstrates the syntax.
# Assuming 'someAsyncFunction' exists and takes a callback:
# someAsyncFunction (value) defer cb value
# msg.payload = "Async operation result: #{value}"
return msg
// 10. Deploy the flow.
// 11. Click the 'Inject' node button. Observe the output in the Debug sidebar.