You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/creating-nodes/first-node.md
+25-12Lines changed: 25 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@ title: Creating your first node
7
7
Nodes get created when a flow is deployed, they may send and receive some messages
8
8
whilst the flow is running and they get deleted when the next flow is deployed.
9
9
10
-
They consist of a pair of files; a JavaScript file that defines what the
10
+
They typically consist of a pair of files; a JavaScript file that defines what the
11
11
node does, and an html file that defines the node's properties, edit dialog and
12
12
help text.
13
13
14
-
When packaged as an npm module, a `package.json` file is used to pull it all together.
14
+
A `package.json` file is used to package it all together as an npm module.
15
15
16
16
-[Creating a simple node](#creating-a-simple-node)
17
17
-[package.json](#package-json)
@@ -25,6 +25,8 @@ When packaged as an npm module, a `package.json` file is used to pull it all tog
25
25
This example will show how to create a node that converts message payloads to
26
26
all lower-case characters.
27
27
28
+
Ensure you have the recommended LTS version of Node.js installed on your system. As of this writing this is version **LTS 8.x** which includes npm version 5.x.
29
+
28
30
Create a directory where you will develop your code. Within that directory,
29
31
create the following files:
30
32
@@ -149,16 +151,27 @@ For more information about the editor part of the node, see [here](node-html).
149
151
150
152
### Testing your node in Node-RED
151
153
152
-
Once you have created a basic node module as described above, you can install
153
-
it into your Node-RED runtime.
154
+
Once you have created a basic node module as described above, you can install it into your Node-RED runtime.
155
+
156
+
To test a node module locally using npm 5.x, the [`npm install <folder>`](https://docs.npmjs.com/cli/install) command can be used. This allows you
157
+
to develop the node in a local directory and have it linked into a local node-red install during development.
158
+
159
+
In your node-red user directory, typically `~/.node-red`, run:
160
+
161
+
npm install <location of node module>
162
+
163
+
For example, if your node is located at `~/dev/node-red-contrib-example-lower-case` you would type the following:
This creates a symbolic link to your node module project directory in `~/.node-red/node_modules` so that Node-RED will discover the node when it starts. Any changes to the node's file can be picked up by simply restarting Node-RED.
154
169
155
-
To test a node module locally, the `npm link` command can be used. This allows you
156
-
to develop the node in a local directory and have it linked into a local node-red
157
-
install, as if it had been npm installed.
170
+
If you are using an older version of npm, you can create a symbolic link manually to your project. To do so:
158
171
159
-
1. in the directory containing the node's `package.json` file, run: `sudo npm link`.
160
-
2. in your node-red user directory, typically `~/.node-red` run: `npm link <name of node module>`.
172
+
cd ~/.node-red/node_modules
173
+
ln -s ~/dev/node-red-contrib-example-lower-case .
161
174
162
-
This creates the appropriate symbolic links between the two directories so Node-RED
163
-
will discover the node when it starts. Any changes to the node's file can be picked
164
-
up by simply restarting Node-RED.
175
+
<divclass="doc-callout">
176
+
<em>Note</em>: npm 5 will add your module as a dependency in the <code>package.json</code> file located in your user directory. To prevent this, use the npm <code>--no-save</code> option.
0 commit comments