Problem with multiple context stores

I've updgraded an old version of Node Red to version v2.1.1
All nodes seem to be working except the Change node does not give the option for using the different context stores.
When Node Red starts, it also does not show which it will use as the Default store (it does use the correct store though).
image

When I used the bash script to upgrade Node Red, I specified the option --node14.
When I try to upgrade again without that option, I get the message "npm does not support Node.js v10.24.1"
How do I get Node.js upgraded permanently?
Could this be the problem with the Change node?

Not sure what is happening now. I tried upgrading again (using the --node16 option). The upgraded Node Red version is v2.1.3 and the Change node shows the correct options (the startup still doesn't show which is the Default store).

I then tried the upgrade again but without the --node16 option and the upgrade failed with the message "npm does not support Node.js v10.24.1".
So my first question still stands (how to get the Node.js upgrade to stay), but the Change node issue may be resolved.

What hardware/OS are you running on?

Show us the full startup log, rather than just a portion of it. Copy/paste the log please rather than screenshot. Use the </> button when pasting the log here.

What do these commands show?

node -v
npm -v
which node
which npm
apt-cache policy nodejs

@Colin
Running raspbian buster on a RPi3bp

Starting as a systemd service.
29 Oct 15:19:38 - [info]
Welcome to Node-RED
===================
29 Oct 15:19:38 - [info] Node-RED version: v2.1.3
29 Oct 15:19:38 - [info] Node.js  version: v16.13.0
29 Oct 15:19:38 - [info] Linux 5.10.63-v7+ arm LE
29 Oct 15:19:40 - [info] Loading palette nodes
29 Oct 15:19:48 - [info] Dashboard version 3.0.4 started at /ui
29 Oct 15:19:49 - [warn] ------------------------------------------------------
29 Oct 15:19:49 - [warn] [node-red-node-rbe/rbe] 'rbe' already registered by module node-red
29 Oct 15:19:49 - [warn] ------------------------------------------------------
29 Oct 15:19:49 - [info] Settings file  : /home/pi/.node-red/settings.js
29 Oct 15:19:49 - [info] Context store  : 'file' [module=localfilesystem]
29 Oct 15:19:49 - [info] Context store  : 'memoryOnly' [module=memory]
29 Oct 15:19:50 - [info] User directory : /home/pi/.node-red
29 Oct 15:19:50 - [warn] Projects disabled : editorTheme.projects.enabled=false
29 Oct 15:19:50 - [warn] Flows file name not set. Generating name using hostname.
29 Oct 15:19:50 - [info] Flows file     : /home/pi/.node-red/flows_RPi3FT.json
29 Oct 15:19:50 - [info] Server now running at http://127.0.0.1:1880/
29 Oct 15:19:50 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
29 Oct 15:19:50 - [info] Starting flows
29 Oct 15:19:50 - [info] Started flows
29 Oct 15:19:50 - [info] [sqlitedb:b9843e17.14ab7] opened /home/pi/dbs/iot.db ok
29 Oct 15:19:51 - [info] [serialconfig:8f2d096.250ddf8] serial port /dev/ttyS0 opened at 115200 baud 8N1
29 Oct 15:19:51 - [info] [mqtt-broker:ba11a02a.c0ebb] Connected to broker: mqtt://localhost:1883
29 Oct 15:19:51 - [info] [mqtt-broker:6199f5b3.1612fc] Connected to broker: mqtt://rpi3ft:1883
29 Oct 15:25:25 - [info] Stopping modified nodes
29 Oct 15:25:25 - [info] Stopped modified nodes
29 Oct 15:25:25 - [info] Starting modified nodes
29 Oct 15:25:25 - [info] Started modified nodes
^C
pi@RPi3FT:~ $ node -v
v16.13.0
pi@RPi3FT:~ $ npm -v
8.1.0
pi@RPi3FT:~ $ which node
/usr/local/bin/node
pi@RPi3FT:~ $ which npm
/usr/local/bin/npm
pi@RPi3FT:~ $ apt-cache policy node.js
node-jstimezonedetect:
  Installed: (none)
  Candidate: 1.0.6-2
  Version table:
     1.0.6-2 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-buffer:
  Installed: (none)
  Candidate: 3.0.0-1
  Version table:
     3.0.0-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-localizer:
  Installed: (none)
  Candidate: 0.0.3-1
  Version table:
     0.0.3-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-stable-stringify:
  Installed: (none)
  Candidate: 1.0.1-1
  Version table:
     1.0.1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-schema-traverse:
  Installed: (none)
  Candidate: 0.3.1-1
  Version table:
     0.3.1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jszip-utils:
  Installed: (none)
  Candidate: 0.0.2+dfsg-1
  Version table:
     0.0.2+dfsg-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsv:
  Installed: (none)
  Candidate: 4.0.0+ds1-1
  Version table:
     4.0.0+ds1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonstream:
  Installed: (none)
  Candidate: 1.3.2-1
  Version table:
     1.3.2-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-schema:
  Installed: (none)
  Candidate: 0.2.3-1
  Version table:
     0.2.3-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-js-cookie:
  Installed: (none)
  Candidate: 2.2.0-2
  Version table:
     2.2.0-2 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsdom:
  Installed: (none)
  Candidate: 0.8.10+dfsg1-1
  Version table:
     0.8.10+dfsg1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsesc:
  Installed: (none)
  Candidate: 2.5.2-1
  Version table:
     2.5.2-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-stringify-safe:
  Installed: (none)
  Candidate: 5.0.1-1
  Version table:
     5.0.1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json3:
  Installed: (none)
  Candidate: 3.3.2-1
  Version table:
     3.3.2-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json5:
  Installed: (none)
  Candidate: 0.5.1-1
  Version table:
     0.5.1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-parse-better-errors:
  Installed: (none)
  Candidate: 1.0.2-2
  Version table:
     1.0.2-2 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-js-yaml:
  Installed: (none)
  Candidate: 3.11.0+dfsg-1
  Version table:
     3.11.0+dfsg-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jssip:
  Installed: (none)
  Candidate: 0.6.34-5
  Version table:
     0.6.34-5 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-loader:
  Installed: (none)
  Candidate: 0.5.4-1
  Version table:
     0.5.4-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonminify:
  Installed: (none)
  Candidate: 0.4.1+dfsg1-1
  Version table:
     0.4.1+dfsg1-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsprim:
  Installed: (none)
  Candidate: 1.4.0-1
  Version table:
     1.4.0-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonselect:
  Installed: (none)
  Candidate: 0.4.0+dfsg3-1
  Version table:
     0.4.0+dfsg3-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonfile:
  Installed: (none)
  Candidate: 5.0.0-1
  Version table:
     5.0.0-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonparse:
  Installed: (none)
  Candidate: 1.3.1-6
  Version table:
     1.3.1-6 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json2module:
  Installed: (none)
  Candidate: 0.0.3-1
  Version table:
     0.0.3-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jszip:
  Installed: (none)
  Candidate: 3.1.4+dfsg-1+deb10u1
  Version table:
     3.1.4+dfsg-1+deb10u1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonify:
  Installed: (none)
  Candidate: 0.0.0-1
  Version table:
     0.0.0-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jschardet:
  Installed: (none)
  Candidate: 1.6.0+dfsg-3
  Version table:
     1.6.0+dfsg-3 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-js-tokens:
  Installed: (none)
  Candidate: 2.0.0-1
  Version table:
     2.0.0-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-js-beautify:
  Installed: (none)
  Candidate: 1.7.5+dfsg-3
  Version table:
     1.7.5+dfsg-3 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-json-parse-helpfulerror:
  Installed: (none)
  Candidate: 1.0.3-2
  Version table:
     1.0.3-2 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsbn:
  Installed: (none)
  Candidate: 1.1.0-1
  Version table:
     1.1.0-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
node-jsonld:
  Installed: (none)
  Candidate: 1.5.3-1
  Version table:
     1.5.3-1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages

can you also show how you configured the contextStorage part in the settings.js file ?

@UnborN

    //contextStorage: {
    //    default: {
    //        module:"localfilesystem"
    //    },
    //},
contextStorage: {
        default: "file",
        file: { module: 'localfilesystem', config: { cache:true , flushInterval: 3600} },
        memoryOnly: { module: 'memory' }
},

    // The following property can be used to order the categories in the editor
 

I beleive the contextStorage should be:

     	contextStorage: {
			default    : { module: 'localfilesystem', config: { cache:true , flushInterval: 3600} },
 			memory     : { module: "memory" }
     	},

@zenofmud
Thanks Paul,
That works.

Oct 29 17:22:39 RPi3FT Node-RED[389]: 29 Oct 17:22:39 - [info] Context store  : 'default' [module=localfilesystem]
Oct 29 17:22:39 RPi3FT Node-RED[389]: 29 Oct 17:22:39 - [info] Context store  : 'memoryOnly' [module=memory]
Oct 29 17:22:39 RPi3FT Node-RED[389]: 29 Oct 17:22:39 - [info] User directory : /home/pi/.node-red

Any thoughts on how to make the Node.js version keep from going back to v10.24.1 when I upgrade without the option --node16?
Or (to paraphrase Steve Jobs) should I just use the --node16 option each time...

what does
node -v
output

Can you post the install log when you get the error please. It tells you where it is at the end. Something like
/var/log/nodered-install.log

Wrong command

I use the same format as @Glake01 and it works fine in the current version of node-RED for me.

contextStorage: {
  default: "memoryOnly",
  memoryOnly: { module: 'memory' },
        file: { module: 'localfilesystem',
                config: {
                        flushInterval: 300
                        },
              },
   },

The advantage with this format, is that when selecting a store, it will display both 'memoryOnly' & 'file' as options to select, so it's easy to select the correct store.

memory

However, if you look closely at your context settings which you pasted above @Glake01 , you missed a comma after a brace, which may of being causing your problem. ie
memoryOnly: { module: 'memory' } instead of memoryOnly: { module: 'memory' },

@Paul-Reed - Paul, I like that! Where did you discover that? It's not in the Context Store API documentation (that I see) and it is not shown in the settings.js when it is built. (I just started NR v2.1.3 with no strings.js so it would create it and I could check)

@cymplecy

Node -v outputs v16.13.0 after I've updated with the --node16 option

Node -voutputs -bash: /usr/local/bin/node: No such file or directory after I try to update without the --node16 option. Also some of my nodes stop working:

30 Oct 10:29:38 - [info] Waiting for missing types to be registered:
30 Oct 10:29:38 - [info]  - serial-port (provided by npm module node-red-node-serialport)
30 Oct 10:29:38 - [info]  - serial out (provided by npm module node-red-node-serialport)
30 Oct 10:29:38 - [info]  - serial in (provided by npm module node-red-node-serialport)
30 Oct 10:29:38 - [info] To install any of these missing modules, run:
30 Oct 10:29:38 - [info]   npm install <module name>
30 Oct 10:29:38 - [info] in the directory:
30 Oct 10:29:38 - [info]   /home/pi/.node-red

It's shown as an example here - Working with context : Node-RED

EDIT, that reminds me, I've been meaning to change those labels!

memory

when I've updated without the --node16 option I get:

 apt-cache policy nodejs
nodejs:
  Installed: 10.24.1-1nodesource1
  Candidate: 10.24.1-1nodesource1
  Version table:
 *** 10.24.1-1nodesource1 100
        100 /var/lib/dpkg/status
     10.24.0~dfsg-1~deb10u1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages

After I've updated with the --node16 option I get:

 apt-cache policy nodejs
nodejs:
  Installed: 10.24.1-1nodesource1
  Candidate: 10.24.1-1nodesource1
  Version table:
 *** 10.24.1-1nodesource1 100
        100 /var/lib/dpkg/status
     10.24.0~dfsg-1~deb10u1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
pi@RPi3FT:~ $ node -v
v16.13.0

This what the log shows for an upgrade without the --node16 option:

Started : Sat Oct 30 10:27:13 MDT 2021
Running for user pi at /home/pi
Found global nodes:   :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodered' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Versions: node:v10.24.1 npm:8.1.1
Now install Node-RED
npm WARN npm npm does not support Node.js v10.24.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN EBADENGINE Unsupported engine { package: 'node-red@2.1.3',
npm WARN EBADENGINE   required: { node: '>=12' },
npm WARN EBADENGINE   current: { node: 'v10.24.1', npm: '8.1.1' } }
npm WARN EBADENGINE Unsupported engine { package: 'fs-extra@10.0.0',
npm WARN EBADENGINE   required: { node: '>=12' },
npm WARN EBADENGINE   current: { node: 'v10.24.1', npm: '8.1.1' } }
npm WARN EBADENGINE Unsupported engine { package: 'node-red-admin@2.2.1',
npm WARN EBADENGINE   required: { node: '>=12' },
npm WARN EBADENGINE   current: { node: 'v10.24.1', npm: '8.1.1' } }

added 290 packages in 49s
2.1.3
Now create basic package.json for the user and move any global nodes
Installing extra nodes: node-red-node-pi-gpio@latest node-red-node-random@latest node-red-node-ping@latest node-red-contrib-play-audio@late$
npm WARN npm npm does not support Node.js v10.24.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN EBADENGINE Unsupported engine { package: 'node-red-dashboard@3.1.0',
npm WARN EBADENGINE   required: { node: '>=12' },
npm WARN EBADENGINE   current: { node: 'v10.24.1', npm: '8.1.1' } }
npm WARN EBADENGINE Unsupported engine { package: 'node-red-node-sqlite@1.0.1',
npm WARN EBADENGINE   required: { node: '>=12' },
npm WARN EBADENGINE   current: { node: 'v10.24.1', npm: '8.1.1' } }

up to date in 9s
Now add the shortcut and start/stop/log scripts to the menu
Now add systemd script and configure it for pi
ln: failed to create symbolic link '/usr/bin/python': File exists
Now add launcher to top bar, add cpu temp example, make sure ping works
The user `pi' is already a member of `gpio'.
Memory  : 1.0G
Started :  Sat Oct 30 10:27:13 MDT 2021
Finished:  Sat Oct 30 10:28:40 MDT 2021
Already have nodejs v10.24.1
OLD nodejs 10 :
NEW nodejs 16 :
Installing nodejs 16 over 10 .

@Paul-Reed

Thanks Paul.

Thank you all for your help!
The context store is working just fine.

I still get the following when I've upgraded node red using the --node16 option so I'll do some Linux Googling to see if I can figure out how to replace v10 with v16 permanently.

pi@RPi3FT:~ $ node -v
v16.13.0
pi@RPi3FT:~ $ apt-cache policy nodejs
nodejs:
  Installed: 10.24.1-1nodesource1
  Candidate: 10.24.1-1nodesource1
  Version table:
 *** 10.24.1-1nodesource1 100
        100 /var/lib/dpkg/status
     10.24.0~dfsg-1~deb10u1 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages

That says that /usr/local/bin/node is node v16.13.0. I think that this is where the script installs node, which is not where the package manager apt would install it.

That says that version 10.24.1 has been installed using apt. So you have two versions installed. I don't know whether possibly you installed that after running the script (by running apt install nodejs or similar) or whether the script did not uninstall it for some reason.
The solution, probably, is to uninstall that version
sudo apt remove nodejs
then try running the script again. I don't know whether you will need the node16 flag or not.

@dceejay I don't know whether you want to look at this and see whether it indicates a deficiency in the script.