# Problem with RED.library in v3.0.x

**URL:** https://discourse.nodered.org/t/problem-with-red-library-in-v3-0-x/66341
**Category:** General
**Created:** [12 August 2022 05:58 UTC](https://discourse.nodered.org/t/problem-with-red-library-in-v3-0-x/66341 "2022-08-12T05:58:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Fredrik](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fredrik/32/107652_2.png) [@Fredrik](https://discourse.nodered.org/u/Fredrik)
#### Post date: [12 August 2022 05:58 UTC](https://discourse.nodered.org/t/problem-with-red-library-in-v3-0-x/66341/1 "2022-08-12T05:58:20Z")

</div>

I'm using RED.library in node-red-contrib-hal2, and I'm having some problems in Node-RED v3.0.x. 'Open library...' no longer works with error

```auto
red.min.js?v=3.0.2:18 Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at Object.create (red.min.js?v=3.0.2:18:493228)
    at Object.create (red.min.js?v=3.0.2:18:445676)
    at Object.createEditor (red.min.js?v=3.0.2:18:421231)
    at Object.onselect (red.min.js?v=3.0.2:18:565468)
    at f (red.min.js?v=3.0.2:18:47362)
    at HTMLAnchorElement.<anonymous> (red.min.js?v=3.0.2:18:46005)
    at HTMLAnchorElement.dispatch (vendor.js?v=3.0.2:2:43090)
    at v.handle (vendor.js?v=3.0.2:2:41074)

```

'Save to library' still works as it should.

I'm guessing there's been a change? I've tried this in v.3.0.0 and v3.0.2.

My library.create:

```auto
            RED.library.create({
                url:"hal2ThingType", 
                type:"hal2ThingType",
                editor:editors['statusFn'],
                fields:[
                    {
                        name: 'name',
                        get: function() { return $("#node-config-input-name").val(); },
                        set: function(v) { $("#node-config-input-name").val(v+' (template copy)'); }
                    },                    
                    {
                        name: 'context_store',
                        get: function() { return contextStore = $("#node-config-input-contextStore").val(); },
                        set: function(v) { $("#node-config-input-contextStore").val((contextStores.includes(v)) ? v : contextStores[0]) }
                    },
                    {
                        name: 'show_state',
                        get: function() { return $("#node-config-input-nodestatus").typedInput('value'); },
                        set: function(v) { $("#node-config-input-nodestatus").typedInput('value',v) }
                    },
                    {
                        name: 'show_statetype',
                        get: function() { return $("#node-config-input-nodestatus").typedInput('type'); },
                        set: function(v) { if (typeof v != 'undefined') { $("#node-config-input-nodestatus").typedInput('type',v); }}
                    },
                    {
                        name: 'ingress',
                        get: function() { return JSON.stringify(getFunctions('ingress')); },
                        set: function(v) {
                            addFunctions('ingress',JSON.parse(v));
                            updateMainTab('ingress');
                            updateHbFunctions();
                            updateFilterFunctions();                            
                        }
                    },
                    {
                        name: 'egress',
                        get: function() { return JSON.stringify(getFunctions('egress')); },
                        set: function(v) {
                            addFunctions('egress',JSON.parse(v));
                            updateMainTab('egress');
                        }
                    },
                    {
                        name: 'filter_function',
                        get: function() { return $("#node-config-input-filterFunction").val(); },
                        set: function(v) { $("#node-config-input-filterFunction").val(v) }
                    },
                    {
                        name: 'attributes',
                        get: function() { return JSON.stringify(getAttributes()); },
                        set: function(v) { addAttributes(JSON.parse(v)); }
                    },
                    {
                        name: 'items',
                        get: function() { return JSON.stringify(getItems()); },
                        set: function(v) { addItems(JSON.parse(v)); }
                    },                    
                    {
                        name: 'check_alive',
                        get: function() { return $("#node-config-input-hbCheck").is(":checked") ? 'true' : 'false'; },
                        set: function(v) { $("#node-config-input-hbCheck").prop("checked",(v == 'true')).trigger('change'); }
                    },
                    {
                        name: 'heartbeat_type',
                        get: function() { return $("#node-config-input-hbType").val(); },
                        set: function(v) { $("#node-config-input-hbType").val(v).trigger('change'); }
                    },
                    {
                        name: 'heartbeat_ttl',
                        get: function() { return $("#node-config-input-hbTTL").val(); },
                        set: function(v) { $("#node-config-input-hbTTL").val(v) }
                    },
                    {
                        name: 'heartbeat_topicfilter',
                        get: function() { return $("#node-config-input-hbFilterVal").typedInput('value'); },
                        set: function(v) { $("#node-config-input-hbFilterVal").typedInput('value',v) }
                    },
                    {
                        name: 'heartbeat_topicfilterType',
                        get: function() { return $("#node-config-input-hbFilterVal").typedInput('type'); },
                        set: function(v) { $("#node-config-input-hbFilterVal").typedInput('type',v); }
                    },
                    {
                        name: 'heartbeat_ingress',
                        get: function() { return ($("#node-config-input-hbLWT").val() === null) ? '' : $("#node-config-input-hbLWT").val(); },
                        set: function(v) { $("#node-config-input-hbLWT").val(v) }
                    },
                    {
                        name: 'heartbeat_timestampProp',
                        get: function() { return ($("#node-config-input-hbPropVal").val() === null) ? '' : $("#node-config-input-hbPropVal").typedInput('value'); },
                        set: function(v) { if (typeof v != 'undefined') { $("#node-config-input-hbPropVal").typedInput('value',v) }}
                    },
                    {
                        name: 'heartbeat_timestampType',
                        get: function() { return ($("#node-config-input-hbPropVal").val() === null) ? '' : $("#node-config-input-hbPropVal").typedInput('type'); },
                        set: function(v) { if (typeof v != 'undefined') { $("#node-config-input-hbPropVal").typedInput('type',v); }}
                    }

                ],
                ext: "template"
            });

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [12 August 2022 06:32 UTC](https://discourse.nodered.org/t/problem-with-red-library-in-v3-0-x/66341/2 "2022-08-12T06:32:25Z")

</div>

There are 2 ways to fix this...

1. add `mode` and/or `title` to the options for `RED.library.create({ title: 'My Library', mode: 'ace/mode/json', url: 'xxx', type: 'xxx', ... }`  
OR
2. upgrade to v3.0.2 (a bug was fixed 3 weeks ago)

Proof in v3.0.2...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14a8fb4c9c0859ed7e2d367b692122f1f1cfbf21.png)

Code used to build that...

```auto
RED.library.create({
    url:"hal2ThingType", 
    type:"hal2ThingType",
    editor: theFuncCodeEditor,
    fields:[
        {
            name: 'name',
            get: function() { return $("#node-input-name").val(); },
            set: function(v) { $("#node-input-name").val(v+' (template copy)'); }
        },
    ],
    ext: "template"
});

```

NOTE: `theFuncCodeEditor` was a temp hack to grab the function nodes editor & provide an editor instance to the library create options

---

<div class="post-metadata">

### Author: ![Fredrik](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fredrik/32/107652_2.png) [@Fredrik](https://discourse.nodered.org/u/Fredrik)
#### Post date: [12 August 2022 07:08 UTC](https://discourse.nodered.org/t/problem-with-red-library-in-v3-0-x/66341/3 "2022-08-12T07:08:15Z")

</div>

Title & mode works perfectly, thank you!

---

<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: [26 August 2022 07:09 UTC](https://discourse.nodered.org/t/problem-with-red-library-in-v3-0-x/66341/4 "2022-08-26T07:09:00Z")

</div>

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