ozomer / node-red-contrib-mongodb2

MongoDB driver node for Node-RED
Apache License 2.0
15 stars 19 forks source link

TypeError: Path must be a string. Received undefined #16

Closed megazero1316 closed 6 years ago

megazero1316 commented 6 years ago

hello

i have been running node-red and use the mongodb2 node for while on nano pi neo air but when i run node-red with supervisor the node disappear and this the output of the log

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

1 Dec 14:41:34 - [info] Node-RED version: v0.17.5
1 Dec 14:41:34 - [info] Node.js  version: v6.9.2
1 Dec 14:41:34 - [info] Linux 3.4.39-h3 arm LE
1 Dec 14:41:36 - [info] Loading palette nodes
1 Dec 14:41:43 - [warn] ------------------------------------------------------
1 Dec 14:41:43 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
1 Dec 14:41:43 - [warn] [mongodb2] TypeError: Path must be a string. Received undefined
1 Dec 14:41:43 - [warn] ------------------------------------------------------
1 Dec 14:41:43 - [info] Settings file  : /home/pi/.node-red/settings.js
1 Dec 14:41:43 - [info] User directory : /home/pi/.node-red
1 Dec 14:41:43 - [info] Flows file     : /home/pi/.node-red/flows_NanoPi-NEO-Air.json
1 Dec 14:41:43 - [info] Creating new flow file
1 Dec 14:41:43 - [info] Starting flows
1 Dec 14:41:43 - [info] Started flows
1 Dec 14:41:43 - [info] Server now running at http://127.0.0.1:1880/

but if i run the node-red normally it appear again and no problem at all

i tried to re install node-red and reinstall mongodb2 node sudo since supervisor run in root mode but no luck

the node-js version i have test it on is : latest 6.12.0 6.9.2

the os used on the nanopi neo air is the officel : Distribution: Ubuntu 16.04.3 LTS Kernel version: Linux 3.4.39-h3 armv7l

ozomer commented 6 years ago

Looks like a problem with your flow. Can you share the flow json file? (notice that it might contain passwords and secret credentials - delete them before sending). I assume that the uri string of the mongodb2 configuration-node is somehow undefined.

megazero1316 commented 6 years ago

my problem is not in the flow itself(as i didnt put my flow yet in node-red), the problem is i cant see the node itself in the node list on the left side of the screen for example when i run node-red using the 'sudo node-red' command

image

but if i run node-red using supervisor 'sudo supervisorctl start NodeRed': image

and when i cat the log file it`s shown like :

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

1 Dec 14:41:34 - [info] Node-RED version: v0.17.5
1 Dec 14:41:34 - [info] Node.js  version: v6.9.2
1 Dec 14:41:34 - [info] Linux 3.4.39-h3 arm LE
1 Dec 14:41:36 - [info] Loading palette nodes
1 Dec 14:41:43 - [warn] ------------------------------------------------------
1 Dec 14:41:43 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
1 Dec 14:41:43 - [warn] [mongodb2] TypeError: Path must be a string. Received undefined
1 Dec 14:41:43 - [warn] ------------------------------------------------------
1 Dec 14:41:43 - [info] Settings file  : /home/pi/.node-red/settings.js
1 Dec 14:41:43 - [info] User directory : /home/pi/.node-red
1 Dec 14:41:43 - [info] Flows file     : /home/pi/.node-red/flows_NanoPi-NEO-Air.json
1 Dec 14:41:43 - [info] Creating new flow file
1 Dec 14:41:43 - [info] Starting flows
1 Dec 14:41:43 - [info] Started flows
1 Dec 14:41:43 - [info] Server now running at http://127.0.0.1:1880/
ozomer commented 6 years ago

This is very strange, but it is hard to believe that this is a problem with mongodb2. What about other node-red packages that you install?

megazero1316 commented 6 years ago

the other libraries is okay , i did quick debugging and actually it`s not only the nanopi but also on my desktop as well ,i go through node-red code and the problem start from here :

`try {
        var loadPromise = null;
        var r = require(node.file);
        if (typeof r === "function") {
            var red = createNodeApi(node);
            var promise = r(red);
            if (promise != null && typeof promise.then === "function") {
                loadPromise = promise.then(function() {
                    node.enabled = true;
                    node.loaded = true;
                    return node;
                }).otherwise(function(err) {
                    node.err = err;
                    return node;
                });
            }
        }
        if (loadPromise == null) {
            node.enabled = true;
            node.loaded = true;
            loadPromise = when.resolve(node);
        }
        return loadPromise;
    } catch(err) {
         node.err = err;
        var stack = err.stack;
        var message;
        if (stack) {
            var i = stack.indexOf(node.file);
            if (i > -1) {
                var excerpt = stack.substring(i+node.file.length+1,i+node.file.length+20);
                var m = /^(\d+):(\d+)/.exec(excerpt);
                if (m) {
                    node.err = err+" (line:"+m[1]+")";
                }
            }
        }`

in node-red/red/runtime/nodes/registry/loader.js

i am still debugging the problem to see why node-red can't load the node when it's used with supervisor

megazero1316 commented 6 years ago

i already solved the problem , actually it`s the configuration file in /etc/supervisor/conf.d/ , the way i set it cause the problem the correct working configuration can be find here :

https://github.com/mattwire/embedded_debian/blob/master/apps/supervisor/conf.d.dist/node-red.conf

ozomer commented 6 years ago

OK, happy for you for solving the problem :smile: , I'm closing the issue.