# Portable Node-RED v2.1.3

**URL:** <https://discourse.nodered.org/t/portable-node-red-v2-1-3/53244>\
**Category:** Share Your Projects\
**Created:** [5 November 2021 04:31 UTC](https://discourse.nodered.org/t/portable-node-red-v2-1-3/53244 "2021-11-05T04:31:15Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [5 November 2021 13:38 UTC](https://discourse.nodered.org/t/portable-node-red-v2-1-3/53244/8 "2021-11-05T13:38:04Z")

</div>

Not sure if this is of any use. Here is a tiny shell script that starts nr with the port number extracted from the current directory, so for example the nr directory holding the flow, settings and node\_modules would be directory\_name#xxxx where xxxx is the port number. If no # found then the default 1880 is used.

I also use yarn so that I can run multiple versions of node on the same host.

```auto
#!/bin/bash
###################
# start-nr.sh
# -----------
# launch node-red with the user dir as the current dir and a port.
#
# If the containing directory name ends in '#n' where n is a number
# e.g. directory-name#1880 
# then the number will be used as the node-red port.
######################

nr_root=$(pwd);
default_port="1880";
port_index=`expr index "$nr_root" "#"`;

if ["$port_index" -eq "0"]; then
   port=$default_port;
else
   new_port=${nr_root:$port_index};
   re='^[0-9]+$';
   if ! [[$new_port =~ $re]] ; then
      port=$default_port;
   else
      port=$new_port;
   fi
fi
params="";
for param in "$@"
do
   params+=" "$param;
done
re='admin';
if ! [[$params =~ $re]] ; then
   cmd=$nr_root"/node_modules/.bin/node-red -u "$nr_root" -p "$port;
else
   cmd=$nr_root"/node_modules/.bin/node-red"$params;
fi
#echo "cmd="$cmd;
exec $cmd

```

For yarn I just batch up a list of commands that I keep in 'yarn-init.sh'.

```auto
yarn add node@14.17.5
yarn add node-red@2.1.3
yarn add node-red-dashboard@3.1.0

```

---

_[View the full topic](https://discourse.nodered.org/t/portable-node-red-v2-1-3/53244)._
