Cannot read property
rikki78 opened this issue · 20 comments
Hi,
I got this error message: "TypeError: Cannot read property 'database' of null" when using this flow:
[{"id":"283dae94.a3da62","type":"tab","label":"Flow 1"},{"id":"7b3d5411.936d9c","type":"myscontroler","z":"283dae94.a3da62","database":"Mysensors","name":"MQTT_Mysensors","handleid":true,"x":493,"y":130,"wires":[["87192538.a6abd8"]]},{"id":"271a8638.2e481a","type":"mqtt in","z":"283dae94.a3da62","name":"","topic":"mygateway1-out/#","qos":"2","broker":"5f4cad33.82b5b4","x":253,"y":130,"wires":[["7b3d5411.936d9c","845e6f52.1887f"]]},{"id":"87192538.a6abd8","type":"debug","z":"283dae94.a3da62","name":"","active":true,"console":"false","complete":"true","x":713,"y":130,"wires":[]},{"id":"845e6f52.1887f","type":"debug","z":"283dae94.a3da62","name":"","active":false,"console":"false","complete":"true","x":493,"y":190,"wires":[]},{"id":"5f4cad33.82b5b4","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Could you give more details how to set up the different nodes?
thanks a lot.
Did you define a location for the database, that is writable by node-red? (when adding the database in the controller node)
So it should be a path to a database? Can you give an example of what I should fill in?
Yes, it's a path to a sqlite database file. The file itself will be created automatically, but it should point to somewhere on the filesystem that is writable.
example:
/tmp/mydb
However, do note that the tmp directory will be deleted now and then, so you should choose a more permanent location for your file.
in my setup I use /data/, as I am running node-red in a docker container. /data is then mapped to a different folder on the docker host.
I'll keep this as a reminder to update documentation
I still have the same error...
I have used the name "mysens" and the database "/home/pi/mysens"
I've tried a couple of other locations too.
The error message appears to me as the object containing 'database' is not available.
I want to use the MQTT controller so have a MQTT node before the controller node.
node red runs under pi and that user has read/write access to the destination file.
I did have some issues when installing the module but after installing sqlite (npm install sqlite) it was ok.
How can I check it is installed correctly?
Hmm.. I think I have misinterpreted the initial error message from the start..
Is it in the UI that you see that error? Or is it in node-red's log file?
Btw. it should pull in sqlite from the start, when you do a npm install node-red-contrib-mysensors. Or did you use a different method for installing the module initially?
I see the error in the UI.
I tried to update using the palette manager but that didn't work, so I did it manually. I also did the installation of sqlite manually.
I saved the initial error messages from when I was updating:
Error: Command failed: npm install --save --save-prefix="" --production node-red-contrib-mysensors@2.0.1"" "--production" "node-red-contrib-mysensors@2.0.1"
npm WARN package.json node-red-project@0.0.1 No repository field.
npm WARN package.json node-red-project@0.0.1 No README data
npm WARN package.json node-red-project@0.0.1 No license field.
npm ERR! Linux 4.4.21-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "--save-prefix="
npm ERR! node v4.6.2
npm ERR! npm v2.15.11
npm ERR! path /home/pi/.node-red/node_modules/node-red-contrib-mysensors/node_modules/sqlite/node_modules/sqlite3
npm ERR! code ENOTEMPTY
npm ERR! errno -39
npm ERR! syscall rmdir
npm ERR! ENOTEMPTY: directory not empty, rmdir '/home/pi/.node-red/node_modules/node-red-contrib-mysensors/node_modules/sqlite/node_modules/sqlite3'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following fi...
Error: Command failed: npm install --save --save-prefix="~" --production node-red-contrib-mysensors@2.0.1
npm WARN package.json node-red-project@0.0.1 No repository field.
npm WARN package.json node-red-project@0.0.1 No README data
npm WARN package.json node-red-project@0.0.1 No license field.
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v46-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.13 and node@4.6.2 (node-v46 ABI) (falling back to source compile with node-gyp)
gyp: binding.gyp not found (cwd: /home/pi/.node-red/node_modules/node-red-contrib-mysensors/node_modules/sqlite/node_modules/sqlite3) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp
failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack...
Perhaps installing thru the palette manager is borked, as it needs to run gyp to build the sqlite bindings.
As a trial, could you try and remove the node-red-contrib-mysensors directory, and do a manual re-install of it with npm, just to check that it pulls in the correct modules etc.
okay I can try that. I only have a live system so I need to be sure it won't mess up anything... Do you think it is likely something will mess up?
You can do it while node-red is running, and then do a restart after you have re-installed the node-red-contrib-mysensors module. So only a short downtime should be experienced..
Also note that 2.1.0 is released as a npm package.. (although it mainly is around the debugging parts, that I've done some work)
Unfortunately this didn't fix it. I followed your instructions but still the same error.
I got these errors during installing
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaw s.com/sqlite3/v3.1.13/node-v46-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.13 and node@4.6.2 (node-v46 ABI) (falling back to source compile with node-gyp)
A wild guess
Do you have node-gyp installed? I think the issue is that you do not get the correct dependencies installed (sqlite3). It can't find the pre-build executable so it want to build it during install. And for building it requires node-gyp to be installed..
npm install -g node-gyp
Sorry I should have been more clear. I got these errors, but the installation finishes. So I guess that is ok. sqlite is installed in the directory node_modules/sqlite
Could it be related to an older version of nodejs? I run 4.6.2
That could be an issue with such an old version of node. My dev (and prod) environments are running in docker containers, and I think it's node 6 that they use currently.
Have to check up on it though..
Also my node-red version is 0.18.4
The node environment in my setup is
docker exec -it nodered /bin/bash
node-red@2f52520823bb:~$ node -v
v6.14.1
ok thanks for checking and for your support.
I think that is the cause than. I have one application that is not (completely) compatible with higher node versions so I first have to fix that. For now I'll use the plugin without the database functionality.
That was one of the reasons that I switched over to docker containers, then nodered is isolated in its own little world.
Documentation updated in the latest release