VueJS component not loading

Hi,

As part of the next step I've been playing with the uibuilder + VueJS.
Last step (well, current last step) before I start to create new UI I wanted to divide my (future) frontend in VueJs components. Well........ Let's just say I'm stuck there for a while now......

To make it short, I've been trying to make dynamic frontend like @UnborN just without compiling like @JM_Energy here: uibuilder-vue-router-without-compiling

So, ATM I just want to make a full navigation without any props or keys - that I'll try to do later.

Node-RED version: v2.2.2
Node.js version: v14.18.0
Windows_NT 10.0.19043 x64 LE
"dependencies": {
"bootstrap": "^5.1.3",
"bootstrap-vue": "^2.21.2",
"http-vue-loader": "^1.4.2",
"normalize.css": "^8.0.1",
"vue": "^2.6.14",
"vue-router": "^3.5.3",
"vuex": "^3.6.2"
}

I've tried to run every example from the forum and github I could find, but I think the problem might be somewhat greater...

I have 2 main problems:

  1. vue component's can't load from any other folder than src
    Errors:
    image

I really don't understand, I've been trying to load the file using httpVueLoader('./views/page1.vue')

  1. When I load the file from src folder, the template content is not displayed at all - only the root navbar vue file.
    I know it loaded becase I see it in the console message. Also, I can only load each file once, after this it won't work anymore.

Any help, info, link would be much appreciated. :+1:

code

index.html

<!doctype html><html lang="en"><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

    <title>http-vue-loader/VueJS Example - Node-RED UI Builder</title>
    <meta name="description" content="Node-RED UI Builder - http-vue-loader/VueJS Example">

    <link rel="icon" href="./images/node-blue.ico">

    <link type="text/css" rel="stylesheet" href="../uibuilder/vendor/bootstrap/dist/css/bootstrap.min.css" />
    <link type="text/css" rel="stylesheet" href="../uibuilder/vendor/bootstrap-vue/dist/bootstrap-vue.css" />

    <link rel="stylesheet" href="./index.css" media="all">
</head><body>
    <div id="app">
        <b-container id="app_container">
            <h1>
                Example of trying new things :)
            </h1>
            <navbar :greeting="myGreeting" :who="myWho"></navbar>
        </b-container>
    </div>

    <script src="../uibuilder/vendor/socket.io/socket.io.js"></script>
    <!-- Use vue.min.js for production use -->
    <script src="../uibuilder/vendor/vue/dist/vue.js"></script>
    <script src="../uibuilder/vendor/bootstrap-vue/dist/bootstrap-vue.js"></script>
    <script src="../uibuilder/vendor/http-vue-loader/src/httpVueLoader.js"></script>
    <script src="../uibuilder/vendor/vue-router/dist/vue-router.js"></script>
    <script src="./uibuilderfe.min.js"></script> <!--    //prod version -->
    <script src="./index.js"></script>

</body></html>

navbar.vue

<template>
    <div>
    <b-row>
        <b-col class="hello" cols="12">
            {{greeting}} {{who}}
        </b-col>
        <slot>
            Default slot content, replace with your own text between the component tags.
            See the <a href="https://vuejs.org/v2/guide/components-slots.html" target="_blank">VueJS documentation for slots</a> for more information.
        </slot>
    </b-row>

    <b-navbar type="dark" variant="dark">
      
      <b-navbar-nav>
        <router-link to="/navbar">BACK</router-link>
        <b-nav-item to="/navbar/page1" exact :active="$route.name == 'page1'">Page 1</b-nav-item>
        <b-nav-item to="/navbar/page2" exact :active="$route.name == 'page2'">Page 2</b-nav-item>
        <router-link :to="{name: 'page1'}" >Go to Page 11</router-link>
        <router-link :to="{name: 'page2'}" >Go to Page 22</router-link>
        <router-link to="/navbar/page1">page111</router-link>
        <router-link to="/navbar/page2">page222</router-link>
        
      </b-navbar-nav>
    </b-navbar>

  </div>
</template>




<script>
module.exports = {
    /** Allow greeting and who to be passed as parameters but provide defaults
     * @see https://vuejs.org/v2/guide/components-props.html#Prop-Validation
     */
    props: {
        'greeting': {type: String, default: 'Hello'},
         'who': {type: String, default: 'World'},
    },

    /** Any data must be wrapped in a fn to isolate it in case this component is used multiple times */
    data: function() { return {

    }}
}
</script>

<style scoped>
.hello {
    background-color: #ffe;
    font-size: 2rem;
    text-align: center;
}
</style>

page2.vue

<template>
    <div>
    <b-row>
        <h1>PAGE 2</h1>
        <b-col class="hello" cols="12">
            {{greeting}} {{who}}
        </b-col>
        <slot>
            
            See the <a href="https://vuejs.org/v2/guide/components-slots.html" target="_blank">VueJS documentation for slots</a> for more information.
        </slot>
    </b-row>

    <b-navbar type="dark" variant="dark">
      
      <b-navbar-nav>
          <router-link to="/navbar">BACK</router-link>
        <b-nav-item to="/page1" exact :active="$route.name == 'page1'">Page 1</b-nav-item>
        <b-nav-item to="/page2" exact :active="$route.name == 'page2'">Page 2</b-nav-item>
        <router-link :to="{name: 'page1'}" >Go to Page 11</router-link>
        <router-link :to="{name: 'page2'}" >Go to Page 22</router-link>
        <router-link to="/navbar/page1">page111</router-link>
        <router-link to="/navbar/page2">page222</router-link>
      </b-navbar-nav>
    </b-navbar>

  </div>
</template>

<script>

    console.log('wow kurac2')
    


module.exports = {
    /** Allow greeting and who to be passed as parameters but provide defaults
     * @see https://vuejs.org/v2/guide/components-props.html#Prop-Validation
     */
    props: {
        'greeting': {type: String, default: 'Hello'},
         'who': {type: String, default: 'World'},
    },

    /** Any data must be wrapped in a fn to isolate it in case this component is used multiple times */
    data: function() { return {

    }}
}
</script>

page1.vue

<template>
    <div>
    <b-row>
        <h1>PAGE 1</h1>
        <b-col class="hello" cols="12">
            {{greeting}} {{who}}
        </b-col>
        <slot>
            
            See the <a href="https://vuejs.org/v2/guide/components-slots.html" target="_blank">VueJS documentation for slots</a> for more information.
        </slot>
    </b-row>

    <b-navbar type="dark" variant="light">
      
      <b-navbar-nav>
          <router-link to="/navbar">BACK</router-link>
        <b-nav-item to="/page1" exact :active="$route.name == 'page1'">Page 1</b-nav-item>
        <b-nav-item to="/page2" exact :active="$route.name == 'page2'">Page 2</b-nav-item>
        <router-link :to="{name: 'page1'}" >Go to Page 11</router-link>
        <router-link :to="{name: 'page2'}" >Go to Page 22</router-link>
        <router-link to="/navbar/page1">page111</router-link>
        <router-link to="/navbar/page2">page222</router-link>
        <router-link to="/navbar">BACK</router-link>
      </b-navbar-nav>
    </b-navbar>

  </div>
</template>
<script>

    console.log('wow kurac')
    


module.exports = {
    /** Allow greeting and who to be passed as parameters but provide defaults
     * @see https://vuejs.org/v2/guide/components-props.html#Prop-Validation
     */
    props: {
        'greeting': {type: String, default: 'Hello'},
         'who': {type: String, default: 'World'},
    },

    /** Any data must be wrapped in a fn to isolate it in case this component is used multiple times */
    data: function() { return {

    }}
}
</script>

index.js

'use strict'


const navbar = httpVueLoader('navbar.vue');
const page2 = httpVueLoader('page2.vue');


const routeDefs = [
    {
        path: '/navbar',
        name: 'navbar',
        components: navbar,        
        children: [
            {
                path: '/navbar/page1',
                name: 'page1',
                component: httpVueLoader('./views/page1.vue')
            },
            {   
                path: '/navbar/page2',
                name: 'page2',
                component: page2
                //component: httpVueLoader('page2.vue')
            }
        ],
        props: {
            string:"From Index",
            number:  33,
            value: "ochenta"
        } 
    }   

    ]

// eslint-disable-next-line no-unused-vars



var app1 = new Vue({
    el: '#app',
        //router,
        router: new VueRouter({routes: routeDefs}),
          
    /** Load external component files
     *  Make sure there is no leading / in the name
     *  To load from the common folder use like: 'common/component-name.vue' */
    components: {
        'navbar':navbar

    }, // --- End of components --- //

    data: {
        myGreeting: 'Hi there',
        myWho: 'oh wise one!',
        //myRoutes: routeDefs, // redefine here so we can push it down
        //myProps: properties,
    }, // --- End of data --- //

    computed: {
    }, // --- End of computed --- //

    methods: {
    }, // --- End of methods --- //

    // Available hooks: init,mounted,updated,destroyed
    mounted: function(){
        /** **REQUIRED** Start uibuilder comms with Node-RED @since v2.0.0-dev3
         * Pass the namespace and ioPath variables if hosting page is not in the instance root folder
         * e.g. If you get continual `uibuilderfe:ioSetup: SOCKET CONNECT ERROR` error messages.
         * e.g. uibuilder.start('/nr/uib', '/nr/uibuilder/vendor/socket.io') // change to use your paths/names
         */
        uibuilder.start()

        var vueApp = this

        // Process new messages from Node-RED
        uibuilder.onChange('msg', function (msg) {
            // We are assuming that msg.payload is an number between zero and 10

            // Change value
            if (msg.payload.hasOwnProperty('greeting')) vueApp.myGreeting = msg.payload.greeting
            if (msg.payload.hasOwnProperty('who')) vueApp.myWho = msg.payload.who

            //console.log(msg)
        })

    } // --- End of mounted hook --- //
    //router: new VueRouter(router)
}) // --- End of app1 --- //

// EOF

First question: Are you using uibuilder v4 or v5? v5 is the version I released yesterday and I would strongly recommend using it.

That is correct. If you aren't doing a build, all of the additional resource files either have to be under src or dist (you can use dist without a build, there is really nothing special about it, just make sure that all files are under one or the other location and choose in the uibuilder config panel in the editor accordingly).

However, you can create sub-folders under src. So I would create something like src/views/ and put the component files there. They can be access from yout front-end code using http://localhost:1880/vue-file/views/page1.vue, or better ./views/page1.vue as in your example.

You need to understand that httpVueLoader takes a URL as its parameter, not a file path.

Yes, that's because you haven't loaded the routes into the navbar. In fact, you've mixed up two different things - here is my previous example:

    <div id="app" class="uib" v-cloak>
        <b-container id="app_container">
            <nav-bar :routes="myRoutes"></nav-bar>

            <h1>http-vue-loader example - Node-RED and uibuilder</h1>

            <my-component :greeting="myGreeting" :who="myWho">
                <p>This text goes into the &lt;slot&gt; tags in the component. try removing this from index.html to see the default text.</p>
            </my-component>

            <pre id="msg" v-html="showLastReceivedMsg" class="syntax-highlight">Waiting for a message from Node-RED</pre>
            
            <h2><router-view name="routeHeading" :key="$route.fullPath"></router-view></h2>
            <router-view myprop="genius" :key="$route.fullPath" v-on:ooh-you-clicked="myclickmethod($event)">In the slot</router-view>
            
        </b-container>
    </div>

Note how the navbar contains a routes property. It is the <my-component> custom attribute (component) that has the greeting and who properties. It is the <router-view> tag that actually loads the route content.

2 Likes

Yes, I (was) running the 4.1.4.

Good point and I'll try that after I figure up the 5.0 I just installed :slight_smile:

I've reinstalled all the npm packages and redeployes my instances but there are still some errors (on Win10 atleast):
image


4 Apr 22:32:15 - [info] +-----------------------------------------------------
4 Apr 22:32:15 - [info] | uibuilder v5.0.0 initialised
4 Apr 22:32:15 - [info] | root folder: \Users\Tomislav\.node-red\uibuilder
4 Apr 22:32:15 - [info] | Using Node-RED's webserver at:
4 Apr 22:32:15 - [info] |   http://null:undefined or http://localhost:undefined/
4 Apr 22:32:15 - [info] | Installed packages:
4 Apr 22:32:15 - [info] |   bootstrap, bootstrap-vue, http-vue-loader, normalize.css
4 Apr 22:32:15 - [info] |   vue, vue-router
4 Apr 22:32:15 - [info] +-----------------------------------------------------
4 Apr 22:32:15 - [info] Starting flows
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:chart_chartkick] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:uib_simple] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:vdebug] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:chart_vue_echarts] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:moon] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:vue-lesson13] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:uiswitch] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:cachetest1] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:chart_apex] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:uibuilder_example] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:chart_vega_basic] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:chart_vega_vue] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:odin20_alpha1] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:odin20_alpha1.1] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:vue-file] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:demo] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:demo2] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:demo3] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:demo_odin_pre_alpha] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:odin_beta] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:addNs:odin_totally] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 22:32:15 - [info] Started flows
4 Apr 22:32:15 - [warn] [uibuilder:socket:onConnect:demo2] sioUse middleware failed to load for NS demo2 - check that uibRoot/.config/sioUse.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:onConnect:odin_beta] sioUse middleware failed to load for NS odin_beta - check that uibRoot/.config/sioUse.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:onConnect:odin_totally] sioUse middleware failed to load for NS odin_totally - check that uibRoot/.config/sioUse.js has a valid exported fn.
4 Apr 22:32:15 - [warn] [uibuilder:socket:onConnect:demo3] sioUse middleware failed to load for NS demo3 - check that uibRoot/.config/sioUse.js has a valid exported fn.

Haha, I see you've been busy :slight_smile:

You can get rid of all of those [warn] [uibuilder:socket:addNs: messages simply by deleting \Users\Tomislav\.node-red\uibuilder\*.js

Here I think is a clue. That second line is obviously wrong. It should show something like http://192.168.1.123:1880 or http://localhost:1880/. (where the ip address is the network ip of the device running Node-RED).

Two things to check:

  1. Are there any errors in the Node-RED log above the start of the log you've shared?
  2. Do you have a uibuilder property in your settings.js file? If so, can you share it please?

Yes :smiley:

I don't have any JavaScript files in uibuilder folder:

Edit: There are only this ones in the .config folder:
image

This is the complete Node-RED log:

4 Apr 23:15:11 - [info]

Welcome to Node-RED
===================

4 Apr 23:15:11 - [info] Node-RED version: v2.2.2
4 Apr 23:15:11 - [info] Node.js  version: v14.18.0
4 Apr 23:15:11 - [info] Windows_NT 10.0.19043 x64 LE
4 Apr 23:15:12 - [info] Loading palette nodes
4 Apr 23:15:13 - [info] mDashboard version 2.19.4-beta started at /mui
4 Apr 23:15:13 - [info] Dashboard version 3.0.4 started at /ui
4 Apr 23:15:14 - [info] Settings file  : C:\Users\Tomislav\.node-red\settings.js
4 Apr 23:15:14 - [info] Context store  : 'default' [module=memory]
4 Apr 23:15:14 - [info] User directory : \Users\Tomislav\.node-red
4 Apr 23:15:14 - [warn] Projects disabled : editorTheme.projects.enabled=false
4 Apr 23:15:14 - [warn] Flows file name not set. Generating name using hostname.
4 Apr 23:15:14 - [info] Flows file     : \Users\Tomislav\.node-red\flows_DESKTOP-QG83EJG.json
(node:12204) [DEP0118] DeprecationWarning: The provided hostname "undefined" is not a valid hostname, and is supported in the dns module solely for compatibility.
(Use `node --trace-deprecation ...` to show where the warning was created)
4 Apr 23:15:14 - [info] Server now running at http://127.0.0.1:1880/
4 Apr 23:15:14 - [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.
---------------------------------------------------------------------

4 Apr 23:15:14 - [info] +-----------------------------------------------------
4 Apr 23:15:14 - [info] | uibuilder v5.0.0 initialised
4 Apr 23:15:14 - [info] | root folder: \Users\Tomislav\.node-red\uibuilder
4 Apr 23:15:14 - [info] | Using Node-RED's webserver at:
4 Apr 23:15:14 - [info] |   http://null:undefined or http://localhost:undefined/
4 Apr 23:15:14 - [info] | Installed packages:
4 Apr 23:15:14 - [info] |   bootstrap, bootstrap-vue, http-vue-loader, normalize.css
4 Apr 23:15:14 - [info] |   vue, vue-router
4 Apr 23:15:14 - [info] +-----------------------------------------------------
4 Apr 23:15:14 - [info] Starting flows
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:chart_chartkick] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:uib_simple] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:vdebug] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:chart_vue_echarts] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:moon] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:vue-lesson13] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:uiswitch] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:cachetest1] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:chart_apex] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:uibuilder_example] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:chart_vega_basic] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:chart_vega_vue] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:odin20_alpha1] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:odin20_alpha1.1] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:vue-file] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:demo] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:demo2] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:demo3] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:demo_odin_pre_alpha] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:odin_beta] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [warn] [uibuilder:socket:addNs:odin_totally] Socket.IO middleware failed to load for NS - check that uibRoot/.config/sioMiddleware.js has a valid exported fn.
4 Apr 23:15:14 - [info] Started flows

There isn't any uibuilder property in settings.js file.

Here is the complete settings file:

settings.js
/**
 * Copyright JS Foundation and other contributors, http://js.foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

module.exports = {
    // the tcp port that the Node-RED web server is listening on
    uiPort: process.env.PORT || 1880,

    // By default, the Node-RED UI accepts connections on all IPv4 interfaces.
    // To listen on all IPv6 addresses, set uiHost to "::",
    // The following property can be used to listen on a specific interface. For
    // example, the following would only allow connections from the local machine.
    //uiHost: "localhost",

    // Retry time in milliseconds for MQTT connections
    mqttReconnectTime: 15000,

    // Retry time in milliseconds for Serial port connections
    serialReconnectTime: 15000,

    // Retry time in milliseconds for TCP socket connections
    //socketReconnectTime: 10000,

    // Timeout in milliseconds for TCP server socket connections
    //  defaults to no timeout
    //socketTimeout: 120000,

    // Maximum number of messages to wait in queue while attempting to connect to TCP socket
    //  defaults to 1000
    //tcpMsgQueueSize: 2000,

    // Timeout in milliseconds for HTTP request connections
    //  defaults to 120 seconds
    //httpRequestTimeout: 120000,

    // The maximum length, in characters, of any message sent to the debug sidebar tab
    debugMaxLength: 1000,

    // The maximum number of messages nodes will buffer internally as part of their
    // operation. This applies across a range of nodes that operate on message sequences.
    //  defaults to no limit. A value of 0 also means no limit is applied.
    //nodeMessageBufferMaxLength: 0,

    // To disable the option for using local files for storing keys and certificates in the TLS configuration
    //  node, set this to true
    //tlsConfigDisableLocalFiles: true,

    // Colourise the console output of the debug node
    //debugUseColors: true,

    // The file containing the flows. If not set, it defaults to flows_<hostname>.json
    //flowFile: 'flows.json',

    // To enabled pretty-printing of the flow within the flow file, set the following
    //  property to true:
    //flowFilePretty: true,

    // By default, credentials are encrypted in storage using a generated key. To
    // specify your own secret, set the following property.
    // If you want to disable encryption of credentials, set this property to false.
    // Note: once you set this property, do not change it - doing so will prevent
    // node-red from being able to decrypt your existing credentials and they will be
    // lost.
    //credentialSecret: "a-secret-key",

    // By default, all user data is stored in a directory called `.node-red` under
    // the user's home directory. To use a different location, the following
    // property can be used
    //userDir: '/home/nol/.node-red/',

    // Node-RED scans the `nodes` directory in the userDir to find local node files.
    // The following property can be used to specify an additional directory to scan.
    //nodesDir: '/home/nol/.node-red/nodes',

    // By default, the Node-RED UI is available at http://localhost:1880/
    // The following property can be used to specify a different root path.
    // If set to false, this is disabled.
    //httpAdminRoot: '/admin',

    // Some nodes, such as HTTP In, can be used to listen for incoming http requests.
    // By default, these are served relative to '/'. The following property
    // can be used to specifiy a different root path. If set to false, this is
    // disabled.
    //httpNodeRoot: '/red-nodes',

    // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
    // to apply the same root to both parts.
    //httpRoot: '/red',

    // When httpAdminRoot is used to move the UI to a different root path, the
    // following property can be used to identify a directory of static content
    // that should be served at http://localhost:1880/.
    //httpStatic: '/home/nol/node-red-static/',

    // The maximum size of HTTP request that will be accepted by the runtime api.
    // Default: 5mb
    //apiMaxLength: '5mb',

    // If you installed the optional node-red-dashboard you can set it's path
    // relative to httpRoot
    mui: { path: "mui" },

    // Securing Node-RED
    // -----------------
    // To password protect the Node-RED editor and admin API, the following
    // property can be used. See http://nodered.org/docs/security.html for details.
    //adminAuth: {
    //    type: "credentials",
    //    users: [{
    //        username: "admin",
    //        password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
    //        permissions: "*"
    //    }]
    //},

    // To password protect the node-defined HTTP endpoints (httpNodeRoot), or
    // the static content (httpStatic), the following properties can be used.
    // The pass field is a bcrypt hash of the password.
    // See http://nodered.org/docs/security.html#generating-the-password-hash
    //httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
    //httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},

    // The following property can be used to enable HTTPS
    // See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
    // for details on its contents.
    // This property can be either an object, containing both a (private) key and a (public) certificate,
    // or a function that returns such an object:
    //// https object:
    //https: {
    //  key: require("fs").readFileSync('privkey.pem'),
    //  cert: require("fs").readFileSync('cert.pem')
    //},
    ////https function:
    // https: function() {
    //     // This function should return the options object, or a Promise
    //     // that resolves to the options object
    //     return {
    //         key: require("fs").readFileSync('privkey.pem'),
    //         cert: require("fs").readFileSync('cert.pem')
    //     }
    // },

    // The following property can be used to refresh the https settings at a
    // regular time interval in hours.
    // This requires:
    //   - the `https` setting to be a function that can be called to get
    //     the refreshed settings.
    //   - Node.js 11 or later.
    //httpsRefreshInterval : 12,

    // The following property can be used to cause insecure HTTP connections to
    // be redirected to HTTPS.
    //requireHttps: true,

    // The following property can be used to disable the editor. The admin API
    // is not affected by this option. To disable both the editor and the admin
    // API, use either the httpRoot or httpAdminRoot properties
    //disableEditor: false,

    // The following property can be used to configure cross-origin resource sharing
    // in the HTTP nodes.
    // See https://github.com/troygoode/node-cors#configuration-options for
    // details on its contents. The following is a basic permissive set of options:
    //httpNodeCors: {
    //    origin: "*",
    //    methods: "GET,PUT,POST,DELETE"
    //},

    // If you need to set an http proxy please set an environment variable
    // called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
    // For example - http_proxy=http://myproxy.com:8080
    // (Setting it here will have no effect)
    // You may also specify no_proxy (or NO_PROXY) to supply a comma separated
    // list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk

    // The following property can be used to add a custom middleware function
    // in front of all http in nodes. This allows custom authentication to be
    // applied to all http in nodes, or any other sort of common request processing.
    //httpNodeMiddleware: function(req,res,next) {
    //    // Handle/reject the request, or pass it on to the http in node by calling next();
    //    // Optionally skip our rawBodyParser by setting this to true;
    //    //req.skipRawBodyParser = true;
    //    next();
    //},


    // The following property can be used to add a custom middleware function
    // in front of all admin http routes. For example, to set custom http
    // headers
    // httpAdminMiddleware: function(req,res,next) {
    //    // Set the X-Frame-Options header to limit where the editor
    //    // can be embedded
    //    //res.set('X-Frame-Options', 'sameorigin');
    //    next();
    // },

    // The following property can be used to pass custom options to the Express.js
    // server used by Node-RED. For a full list of available options, refer
    // to http://expressjs.com/en/api.html#app.settings.table
    //httpServerOptions: { },

    // The following property can be used to verify websocket connection attempts.
    // This allows, for example, the HTTP request headers to be checked to ensure
    // they include valid authentication information.
    //webSocketNodeVerifyClient: function(info) {
    //    // 'info' has three properties:
    //    //   - origin : the value in the Origin header
    //    //   - req : the HTTP request
    //    //   - secure : true if req.connection.authorized or req.connection.encrypted is set
    //    //
    //    // The function should return true if the connection should be accepted, false otherwise.
    //    //
    //    // Alternatively, if this function is defined to accept a second argument, callback,
    //    // it can be used to verify the client asynchronously.
    //    // The callback takes three arguments:
    //    //   - result : boolean, whether to accept the connection or not
    //    //   - code : if result is false, the HTTP error status to return
    //    //   - reason: if result is false, the HTTP reason string to return
    //},

    // The following property can be used to seed Global Context with predefined
    // values. This allows extra node modules to be made available with the
    // Function node.
    // For example,
    //    functionGlobalContext: { os:require('os') }
    // can be accessed in a function block as:
    //    global.get("os")
    functionGlobalContext: {
        // os:require('os'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },
    // `global.keys()` returns a list of all properties set in global context.
    // This allows them to be displayed in the Context Sidebar within the editor.
    // In some circumstances it is not desirable to expose them to the editor. The
    // following property can be used to hide any property set in `functionGlobalContext`
    // from being list by `global.keys()`.
    // By default, the property is set to false to avoid accidental exposure of
    // their values. Setting this to true will cause the keys to be listed.
    exportGlobalContextKeys: false,


    // Context Storage
    // The following property can be used to enable context storage. The configuration
    // provided here will enable file-based context that flushes to disk every 30 seconds.
    // Refer to the documentation for further options: https://nodered.org/docs/api/context/
    //
    //contextStorage: {
    //    default: {
    //        module:"localfilesystem"
    //    },
    //},

    // The following property can be used to order the categories in the editor
    // palette. If a node's category is not in the list, the category will get
    // added to the end of the palette.
    // If not set, the following default order is used:
    //paletteCategories: ['subflows', 'common', 'function', 'network', 'sequence', 'parser', 'storage'],

    // Configure the logging output
    logging: {
        // Only console logging is currently supported
        console: {
            // Level of logging to be recorded. Options are:
            // fatal - only those errors which make the application unusable should be recorded
            // error - record errors which are deemed fatal for a particular request + fatal errors
            // warn - record problems which are non fatal + errors + fatal errors
            // info - record information about the general running of the application + warn + error + fatal errors
            // debug - record information which is more verbose than info + info + warn + error + fatal errors
            // trace - record very detailed logging + debug + info + warn + error + fatal errors
            // off - turn off all logging (doesn't affect metrics or audit)
            level: "info",
            // Whether or not to include metric events in the log output
            metrics: false,
            // Whether or not to include audit events in the log output
            audit: false
        }
    },

    // Customising the editor
    editorTheme: {
        projects: {
            // To enable the Projects feature, set this value to true
            enabled: false
        }
    }
}

Also, I noticed there isn't uibRoot folder - maybe it's hidden? I've tried ls -Force in PowerShell but I still cant see it

Sorry, my bad, I wasn't concentrating. \Users\Tomislav\.node-red\uibuilder\.config\*.js - sorry about that.

Yes, that's the one :slight_smile:

uibRoot is a reference rather than a real folder. I refer to uibRoot or more usually <uibRoot> to indicate that it is a placeholder rather than a real folder. By default, <uibRoot> refers to \Users\Tomislav\.node-red\uibuilder\ in your case. But you can move the uibRoot folder to somewhere else with a setting in settings.js - but you don't have that so we don't need to be concerted about it for now.


OK, so you win tonight's prize! You found several issues, all of which, I think I've fixed. I'll be publishing a new v5.0.1 version in 20 minutes or so. Please update to that version when it is available.

OK, 5.0.1 released

1 Like

Thank you Julian - and sorry I haven't had time to test the vNext before the 5.0 came.

You were right about the warn messages - there aren't any after removing the *.js files.

The instances are working now at my work PC.
After I get home and test the other one I'll let you know.

The log
U:\>node-red
5 Apr 07:24:22 - [info]

Welcome to Node-RED
===================

5 Apr 07:24:22 - [info] Node-RED version: v2.1.6
5 Apr 07:24:22 - [info] Node.js  version: v14.16.1
5 Apr 07:24:22 - [info] Windows_NT 10.0.19043 x64 LE
5 Apr 07:24:24 - [info] Loading palette nodes
5 Apr 07:24:30 - [info] mDashboard version 2.19.4-beta started at /mui
5 Apr 07:24:36 - [info] Dashboard version 2.30.0 started at /ui
5 Apr 07:24:36 - [info] Settings file  : C:\Users\rtkl1\.node-red\settings.js
5 Apr 07:24:36 - [info] HTTP Static    : C:\Users\rtkl1\.node-red\node-red-static
5 Apr 07:24:36 - [info] Context store  : 'default' [module=memory]
5 Apr 07:24:36 - [info] User directory : C:\Users\rtkl1\.node-red
5 Apr 07:24:36 - [warn] Projects disabled : editorTheme.projects.enabled=false
5 Apr 07:24:36 - [warn] Flows file name not set. Generating name using hostname.
5 Apr 07:24:36 - [info] Flows file     : C:\Users\rtkl1\.node-red\flows_TOMISLAV.json
5 Apr 07:24:36 - [info] Server now running at http://127.0.0.1:1880/
5 Apr 07:24:36 - [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.
---------------------------------------------------------------------

5 Apr 07:24:36 - [info] +-----------------------------------------------------
5 Apr 07:24:36 - [info] | uibuilder v5.0.1 initialised
5 Apr 07:24:36 - [info] | root folder: C:\Users\rtkl1\.node-red\uibuilder
5 Apr 07:24:36 - [info] | Using Node-RED's webserver at:
5 Apr 07:24:36 - [info] |   http://0.0.0.0:1880/
5 Apr 07:24:36 - [info] | Installed packages:
5 Apr 07:24:36 - [info] |   bootstrap, bootstrap-vue, http-vue-loader, jquery
5 Apr 07:24:36 - [info] |   normalize.css, vega, vega-embed, vue
5 Apr 07:24:36 - [info] |   vue-router
5 Apr 07:24:36 - [info] +-----------------------------------------------------
5 Apr 07:24:36 - [info] Starting flows
5 Apr 07:24:36 - [info] Started flows
5 Apr 07:24:36 - [info] [sqlitedb:b17145b6.55f138] opened quilters_data.db ok
5 Apr 07:24:36 - [info] [sqlitedb:5f640143.882b6] opened db1.db ok
5 Apr 07:24:36 - [info] [sqlitedb:e6f1ebca.19e6a8] opened db2.db ok

Thanks again :+1:

There are, however, some warning messages in the browser console (for example in the "uib_simple" instance - your example with the quote of the day):

"/uibuilder_simple_testing" - this is the instance I deleted a while ago. Where is this written?

When you removed a uibuilder instance before v5, it left behind the front-end code in case you wanted to keep it. In v5, you now get a message in the Editor asking if you want to delete the folder as well and you get to choose.

So for older instances that you've deleted. You need to manually delete the folder. In this case, the folder would be C:\Users\rtkl1\.node-red\uibuilder\uibuilder_simple_testing.

However, I don't think that is the problem. It looks to me as though you've probably passed the namespace parameter into uibuilder.start() in another test instance (the one that you actually have open when you are looking at that dev tools log). Did you do a copy/paste?

Well, maybe i did - but I'm not sure. On my home PC, however, everything works OK after update to 5.0.1. :+1:

For the page navigation, I'll play with it and report back if there's some problems.
I must have cought a flu or something so I can't work so much

1 Like

Stay safe and look after yourself. Hope all is well.

Everything OK now, thank you.

I've been lokking in the docs about the V5.0.1 control messages, but I can't seem to find how to enable them again - to send the message when client connected.

uibuilder 5.0.1
using default "VueJs & bootstrap-vue" template

I've tried:

        uibuilder.onChange('ioConnected', function(connected){
            app.socketConnectedState = connected
            uibuilder.send('Client connected')
            console.log('connected')
        })

Only the console message was sent

You don't need to do anything. uibuilder takes care of that for you.

When a client disconnects for any reason and then later reconnects - e.g. if you have a uibuilder page open on a laptop that then goes to sleep and you later wake it up - it will automatically reconnect and when it does, it sends and receives the same handshake control messages as if you had connected for the first time. So just connect something to port 2 (the bottom output connection on the node) to see the messages.

This is actually something that is on the backlog to try and improve because it would be very useful to be able to differentiate between a new connection and a reconnection because with a reconnection, you probably don't really need to resend cached messages.

It works now. For some reason it wasnt sending any control messages.

Edit:
I don't understand. I've got 3 instances which I'm reloading and only one of them sends the control messages for all three:


So If I reload chart_vega_vue the messages are sent from odin20_alpha1.1^

Edit2: Sorry, all what was needed was to clear the browser cache

Hi, a quick tip. You don't need to create multiple uibuilder nodes for multiple pages. one node can happily support many pages. Only the main index.html page is linked from the node but all other .html files are also fully accessible.

Obviously, 1 uibuilder node only creates 1 websocket namespace though and that is the limitation. Each page will connect to the same namespace and receive all of the msgs from that node. You can, of course use the msg.topic or some other data to target msgs for specific pages.

Yes I know - some of them are forum examples, while the other ones are me trying stuff - this flow is only for experimentation. You should see my other experimentation flow :slight_smile:
The real thing is going to be installed on a Rpi anyways :+1:

But there is so much to learn - the thing is when you make something in NodeJS backend + Node-RED dashboard you think you know something..... Nothing compares to learning this vuejs+bootstrap+vuerouter..

1 Like

Yes, unfortunately, it can be a bit overwhelming. However, I hope you will find that once you've got beyond these initial hurdles, you will find things surprisingly straight-forwards. With the help of bootstrap-vue, you can make some amazing UI's with very little code indeed.

Did you try to follow the A first-timers walkthough of using uibuilder article in the Tech Docs? Hopefully it is logical enough to help you bed in the basics.

At the moment, I'm continuing to look at what can be done using pure web components without any front-end framework. This will also benefit people using frameworks since web components are just HTML tags and so can be used anywhere.

This is part of the journey to getting ever lower-code solutions to creating data-driven web UI's :grinning:

The good news for people investing in uibuilder now is that those efforts will still benefit you, you won't have to ditch everything and start again. Instead you should be able to continually incorporate few capabilities and simplify code.

Anyway, as always, let me know if there is documentation missing or wrong or if you think you need some feature adding to uibuilder. I'm always looking for ideas and improvements from other people.

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