Rasp-Node-Red-Install-Node

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche



MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Node-Red comes with an excellent set of basic nodes within its palette however there are more out there and there is certainly nothing stopping you from writing your own!

Some of the nodes also have dependencies on external libraries and without these being installed will not function correctly. As an example for the twitter node to work correctly you need OAuth which allows you to authenticate with twitter.com to be able to send/receive tweets.

You may remember from the initial starting of node red we saw a list of these missing dependencies as shown below.

25 Jan 11:31:45 - [red] Loading palette nodes
25 Jan 11:31:45 - ------------------------------------------
25 Jan 11:31:54 - [61-email.js] Error: Cannot find module '/home/pi/node-red/../emailkeys.js'
25 Jan 11:31:54 - [imap] : Failed to load Email credentials
25 Jan 11:31:55 - [66-mongodb.js] Error: Cannot find module 'mongodb'
25 Jan 11:31:57 - [74-swearfilter.js] Error: Cannot find module 'badwords'
25 Jan 11:31:57 - [72-wordpos.js] Error: Cannot find module 'wordpos'
25 Jan 11:31:57 - [78-ledborg.js] Warning: PiBorg hardware : LedBorg not found
25 Jan 11:31:57 - [76-blinkstick.js] Error: Cannot find module 'blinkstick'
25 Jan 11:31:57 - [77-blink1.js] Error: Cannot find module 'node-blink1'
25 Jan 11:31:57 - [78-digiRGB.js] Error: Cannot find module 'node-hid'
25 Jan 11:31:57 - [103-hue_discover.js] Error: Cannot find module 'node-hue-api'
25 Jan 11:31:57 - [104-hue_manage.js] Error: Cannot find module 'node-hue-api'
25 Jan 11:31:57 - [103-hue_discover.js] Error: Cannot find module 'node-hue-api'
25 Jan 11:31:58 - [104-hue_manage.js] Error: Cannot find module 'node-hue-api'
25 Jan 11:31:58 - [101-scanBLE.js] Error: Cannot find module 'noble'
25 Jan 11:31:58 - [79-sensorTag.js] Error: Cannot find module 'sensortag'
25 Jan 11:31:58 - [60-wemo.js] Error: Cannot find module 'wemo'
25 Jan 11:31:58 - [26-rawserial.js] Advise: Only really needed for Windows boxes without serialport npm module installed.
25 Jan 11:31:58 - [39-wol.js] Error: Cannot find module 'wake_on_lan'
25 Jan 11:31:58 - [69-mpd.js] Error: Cannot find module 'komponist'
25 Jan 11:31:58 - [57-notify.js] Error: Cannot find module 'growl'
25 Jan 11:31:58 - [57-prowl.js] Error: Cannot find module 'node-prowl'
25 Jan 11:31:58 - [57-pushbullet.js] Error: Cannot find module 'pushbullet'
25 Jan 11:32:00 - [56-twilio.js] Error: Failed to load Twilio credentials
25 Jan 11:32:00 - [92-xmpp.js] Error: Cannot find module 'simple-xmpp'

You may have more in your list as I have installed quite a few but the main point is that the "Cannot find module 'X'" is Node-Red telling us that we have a missing dependency.

Luckily it is very easy to install these and as an example if we wanted to install the swear filter node, which filters out bad words we just simply have to carry out the following steps.

First stop node red if it is running using the management script from earlier on in the tutorial.

sudo service node_red stop

Then ensure you are within your Node-Red directory. If you have been following this tutorial yours will match mine as shown below.

cd ~/node-red/

Next we use node package manager to install the dependency for us, which is named exactly as the "Cannot find module" statement told us.

sudo npm install badwords

You will then see the package being installed.

npm http GET https://registry.npmjs.org/badwords
npm http 200 https://registry.npmjs.org/badwords
npm http GET https://registry.npmjs.org/badwords/-/badwords-0.0.3.tgz
npm http 200 https://registry.npmjs.org/badwords/-/badwords-0.0.3.tgz
badwords@0.0.3 node_modules/badwords

Once that has completed we can start Node-Red up again and you will be able to now use the Swear Filter node.

sudo service node_red start

(ou la commande systemclt appropriée si vous utilisez systemD).

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

To ease the pain of you having to go through the whole process each time for each module I have constructed a list of the common modules that you will need to install.

Simply stop Node-Red and follow the process as we did for the bad words example but replace sudo npm install badwords with the following line.

sudo npm install ntwitter oauth sentiment wordpos xml2js firmata fs.notify serialport feedparser pushbullet irc simple-xmpp redis mongodb

Source: Raspberry Pi Hosting Node-Red
Créé par C. Mobberley pour AdaFruit Industries.

Traduction réalisée et augmentée par Meurisse D. pour MCHobby.be.

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com