# New version of NR, lost in \`settings.js\` file

**URL:** <https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165>\
**Category:** General\
**Created:** [14 December 2021 11:49 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165 "2021-12-14T11:49:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 December 2021 11:49 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/1 "2021-12-14T11:49:35Z")

</div>

Sorry folks.

After a lot of messing around, I nearly have the machine working.

In the old version I could set a variable to set the device's name.

```auto
    functionGlobalContext: {
        // os:require('os'),
        // octalbonescript:require('octalbonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
        myDeviceName: "TelePi"
    },

```

I have tried in the new settings file:

```auto
    functionGlobalContext: {
        myDeviceName: "TelePi"
        // os:require('os'),
    },

```

Looking in the `context` for that machine:

![Screenshot from 2021-12-14 22-47-31](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2d1a1aa9676fc944671a461a818f7c1836b4f285.png)

compared to the other machine's settings:

![Screenshot from 2021-12-14 22-48-30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/97ba37f1295c2428ec274e8099ee10450a4dbefc.png)

What am I missing?

NR 2.1.4 and 2.1.3

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 December 2021 11:51 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/2 "2021-12-14T11:51:05Z")

</div>

> [@Trying\_to\_learn](#):
>
> What am I missing?

Check you have `exportGlobalContextKeys` set to `true` in your settings file (it is `false` by default).

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 December 2021 12:00 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/3 "2021-12-14T12:00:06Z")

</div>

(Machine restarting NR)

Gee there is a substantial change in the `settings.js` file between 2.1.3 and 2.1.4!

I guess it is just a case of sitting down and going through them.  
But basically they are sectionalised in pretty much the same order?

(Nearly running)

Ok, so the `settings.js` can't exactly be copied from a `1.x` to `2.x` version - no? (or yes?)

I am also seeing this _message_:  
(sorry)

```auto
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.

```

Ok. I thought I had done that. (Moving on)  
I copy the `flows.json` and `flows_cred.json` file from their backup.

The `flows.json` has gone from `1.3 meg` to `2.2 meg` in size.  
??

# (machine now running NR) It worked!

(setting that line as you said.)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 December 2021 12:44 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/4 "2021-12-14T12:44:57Z")

</div>

Hmm maybe "no problems so far" was speaking too soon...

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 December 2021 12:52 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/5 "2021-12-14T12:52:37Z")

</div>

Now I have a problem with a Python script.  
`paho-mqtt` was _MIA_ so I had to (re)install it.  
and I thought the bigger `mqtt` set was also missing, but no: it was still here.

But now I am getting an error in the python3 code:

```auto
pi@TelePi:~/Pimoroni/blinkt $ python3 blinkt_ctl.py 
Traceback (most recent call last):
  File "blinkt_ctl.py", line 93, in <module>
    client = mqtt.Mosquitto()
AttributeError: module 'paho.mqtt.client' has no attribute 'Mosquitto'
pi@TelePi:~/Pimoroni/blinkt $ 

```

line 93:  
`client = mqtt.Mosquitto()`  
But that should be ok from:  
`import paho.mqtt.client as mqtt` way up in the early lines.

It worked before the update from Jessie to Buster.

---

<div class="post-metadata">

**Author:** ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)\
**Post date:** [22 December 2021 18:14 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/7 "2021-12-22T18:14:07Z")

</div>

Have you solved this? I have the same exact problem on one of my Pi's. Another Pi, built from almost the same image, does not have the problem.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 December 2021 18:26 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/8 "2021-12-22T18:26:43Z")

</div>

> [@Mastiff](#):
>
> I have the same exact problem on one of my Pi's

Exactly which problem? There are several in this thread.

---

<div class="post-metadata">

**Author:** ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)\
**Post date:** [22 December 2021 18:30 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/9 "2021-12-22T18:30:34Z")

</div>

Weird, I thought I quoted... 😱 I meant the Paho MQTT problem in the last post.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [22 December 2021 19:51 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/10 "2021-12-22T19:51:57Z")

</div>

I found the problem with `PahoMQTT`

A command I used had been ...... removed.  
I had to change it to a _different_ one.

The case in point:

`client = mqtt.Mosquitto()`

became

`client = mqtt.Client("LED blink routine")`

Which is kind of better as now the window that was opened has a name I specify.

---

<div class="post-metadata">

**Author:** ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)\
**Post date:** [23 December 2021 17:38 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/11 "2021-12-23T17:38:01Z")

</div>

Thanks! I'll try to implement that, then. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 January 2022 17:38 UTC](https://discourse.nodered.org/t/new-version-of-nr-lost-in-settings-js-file/55165/12 "2022-01-06T17:38:15Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
