Skip to content

Build Node-red nodes using ES6+ and esm module system with the nrg cli

License

Notifications You must be signed in to change notification settings

AllanOricil/node-red-node-esm-template

Repository files navigation

build status

node-red-node-esm-template

This project illustrates the utilization of the nrg CLI for the development of Node-RED nodes.

📁 Directory Structure

This project is built using the nrg cli.

node-red-node-es-template/
└── src/
    └── nodes/
        ├── node-1/
        │   ├── client/
        │   │   ├── locales/
        │   │   │   ├── labels/
        │   │   │   │   ├── de.json
        │   │   │   │   └── en-US.json
        │   │   │   └── docs/
        │   │   │       ├── de.html
        │   │   │       └── en-US.html
        │   │   ├── icons/
        │   │   │   └── icon-1.png
        │   │   ├── index.html
        │   │   └── index.js
        │   └── server/
        │       └── index.js
        └── node-2/
            ├── client/
            │   ├── locales/
            │   │   ├── labels/
            │   │   │   ├── de.json
            │   │   │   └── en-US.json
            │   │   └── docs/
            │   │       ├── de.html
            │   │       └── en-US.html
            │   ├── icons/
            │   │   └── icon-2.png
            │   ├── index.html
            │   └── index.js
            └── server/
                └── index.js

dist

node-red-node-es-template/
└── dist/
    ├── icons/
    │   ├── icon-1.png
    │   └── icon-2.png
    ├── locales/
    │   ├── de/
    │   │   ├── index.html
    │   │   └── index.json
    │   └── en-US/
    │       ├── index.html
    │       └── index.json
    ├── index.html
    ├── index.js.map
    └── index.js

💻 Dev Environment Requirements

Tool Version
node >= 18
npm >= 10

📖 How to test your node

  1. open a terminal in the root of this project
  2. run npm install
  3. run npm run start and wait for your browser to open
  4. verify that 4 nodes are available in the pallete, in the "custom nodes" group.

📖 Other commands

All the following commands are set in the scripts section of package.json and were created using the nrg CLI.

npm run build

Builds the project for production.

npm run build:dev

Builds the project for development.

npm run start

Starts Node-RED with nodes built for development.

npm run start:prod

Starts Node-RED with nodes built for production.

npm run start:debug

Starts Node-RED with nodes built for development and enables debug mode, allowing you to attach a debugger to the server side.

npm run watch

Starts Node-RED with nodes built for development and enables watch mode. This will automatically rebuild your nodes, restart the flows, and refresh/open the browser whenever changes are made to files in ./src.

npm run watch:debug

Starts Node-RED with nodes built for development in both watch and debug modes. This setup allows you to automatically rebuild, restart, and debug the server side with the ability to attach a debugger.

Creating Nodes

If you have the nrg CLI installed globaly, you can create a new node with the following commnad:

nrg create node -n my-node-name

or, if you have it installed as a dev dependency, you can use:

./node_modules/.bin/nrg create node -n my-node-name

Starting a new nrg project

If you have the nrg CLI installed globally, you can run the following commands to get started:

nrg create -n my-nrg-project
cd my-nrg-project

npm install
# pnpm install
# yarn install

About

Build Node-red nodes using ES6+ and esm module system with the nrg cli

Topics

Resources

License

Stars

Watchers

Forks